/** * Reads the snippet of all theme ini files and write them * into the database. * * The theme snippet namespace are prefixed with themes/theme-name */ private function synchronizeSnippets(Shop\Template $template) { $directory = $this->pathResolver->getSnippetDirectory($template); if (!file_exists($directory) || !$this->snippetConfig['writeToDb']) { return; } $namespace = $this->util->getSnippetNamespace($template); $this->snippetWriter->loadToDatabase($directory, false, $namespace); }
/** * Helper function which collects the defined theme javascript * files for the passed shop template. * This function uses a recursive call to collect * all files of the template inheritance. * * @param Shop\Template $template * @return array */ private function getJavascriptFilesRecursive(Shop\Template $template) { $theme = $this->util->getThemeByTemplate($template); $files = $theme->getJavascript(); $directory = $this->pathResolver->getPublicDirectory($template); foreach ($files as &$file) { $file = $directory . DIRECTORY_SEPARATOR . $file; } if ($template->getParent() instanceof Shop\Template) { $files = array_merge($this->getJavascriptFilesRecursive($template->getParent()), $files); } return $files; }
/** * This function handles the configuration inheritance for the synchronization. * The function handles the inheritance over a recursive call. * * First this function is called with the theme which should be synchronized. * If the theme uses a inheritance configuration, the * function resolves the theme parent and calls the "createConfig" function * of the Theme.php. * The Form\Container\TabContainer won't be initialed again, so each * inheritance level becomes the same container instance passed into their * createConfig() function. * * This allows the developer to display the theme configuration of extened * themes. * * @param Theme $theme * @param Form\Container\TabContainer $container * @return Form\Container\TabContainer */ private function injectConfig(Theme $theme, Form\Container\TabContainer $container) { //check if theme wants to inject parent configuration if (!$theme->useInheritanceConfig() || $theme->getExtend() == null) { return; } /**@var $template Shop\Template */ $template = $this->repository->findOneBy(array('template' => $theme->getTemplate())); //no parent configured? cancel injection. if (!$template->getParent()) { return; } //get Theme.php instance of the parent template $parent = $this->util->getThemeByTemplate($template->getParent()); $this->injectConfig($parent, $container); $parent->createConfig($container); }
/** * Returns the snippet namespace for the passed template. * * @param Shop\Template $template * @return \Enlight_Components_Snippet_Namespace */ private function getConfigSnippetNamespace(Shop\Template $template) { return $this->snippets->getNamespace($this->util->getSnippetNamespace($template) . 'backend/config'); }