示例#1
0
 /**
  * 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;
 }
示例#2
0
 /**
  * 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);
 }
示例#3
0
 /**
  * Returns the configuration sets for the passed template.
  * This function returns additionally the inheritance
  * configuration sets of the passed template.
  * The sets are translated automatically.
  *
  * @param Shop\Template $template
  * @return array
  */
 public function getConfigSets(Shop\Template $template)
 {
     $builder = $this->entityManager->createQueryBuilder();
     $builder->select(array('template', 'sets'))->from('Shopware\\Models\\Shop\\Template', 'template')->innerJoin('template.configSets', 'sets')->where('sets.templateId = :templateId')->orderBy('sets.name')->setParameter('templateId', $template->getId());
     $themes = $builder->getQuery()->getArrayResult();
     $namespace = $this->getConfigSnippetNamespace($template);
     $namespace->read();
     foreach ($themes as &$theme) {
         $theme = $this->translateThemeData($theme, $namespace);
         foreach ($theme['configSets'] as &$set) {
             $set = $this->translateConfigSet($set, $namespace);
         }
     }
     $instance = $this->util->getThemeByTemplate($template);
     if ($template->getParent() instanceof Shop\Template && $instance->useInheritanceConfig()) {
         $themes = array_merge($themes, $this->getConfigSets($template->getParent()));
     }
     return $themes;
 }