$this->getParent($compiler, $attributes), ]; } protected function getParent(object $compiler, array $attributes) { $_template = $compiler->template; $source = $compiler->template->source; $bundle = ''; if (!$bundle) { if ($source->smarty->_current_file === null && $_template) { $filePath = $_template->source->filepath; } else { $filePath = $source->smarty->_current_file; } $directories = $source->smarty->getTemplateDir(); foreach ($directories as $dir_bundle => $_directory) { if (\KupShop\KupShopBundle\Util\StringUtil::startsWith($filePath, $_directory)) { $bundle = $dir_bundle; break; } } if (!$bundle) { throw new \Exception('Cannot detect current bundle'); } } $current_file = preg_replace('/\[(.*)\]/i', '', $_template->source->name); $directories = $source->smarty->getTemplateDir(); $found = false; foreach ($directories as $dir_bundle => $_directory) { if (!$found) { if ($bundle == $dir_bundle) { $found = true; } } else { $_filepath = $_directory.$current_file; // TODO: chybejici metoda fileExists // if ($this->fileExists($source, $_filepath)) if (file_exists($_filepath)) { return "'[{$dir_bundle}]{$current_file}'"; } } } throw new \Exception('Extended template doesn\'t found!'); } }