/**
  * {@inheritDoc}
  */
 public function setPlugin($plugin)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPlugin', array($plugin));
     return parent::setPlugin($plugin);
 }
Example #2
0
 /**
  * Helper function which iterates the engine\Shopware\Themes directory
  * and registers all stored themes within the directory as \Shopware\Models\Shop\Template.
  *
  * @param \DirectoryIterator $directories
  * @param \Shopware\Models\Plugin\Plugin $plugin
  * @return Theme[]
  */
 private function synchronizeThemeDirectories(\DirectoryIterator $directories, Plugin $plugin = null)
 {
     $themes = array();
     $settings = $this->service->getSystemConfiguration(AbstractQuery::HYDRATE_OBJECT);
     /**@var $directory \DirectoryIterator */
     foreach ($directories as $directory) {
         //check valid directory
         if ($directory->isDot() || !$directory->isDir() || $directory->getFilename() == '_cache') {
             continue;
         }
         try {
             $theme = $this->util->getThemeByDirectory($directory);
         } catch (\Exception $e) {
             continue;
         }
         $data = $this->getThemeDefinition($theme);
         $template = $this->repository->findOneBy(array('template' => $theme->getTemplate()));
         if (!$template instanceof Shop\Template) {
             $template = new Shop\Template();
             if ($plugin) {
                 $template->setPlugin($plugin);
             }
             $this->entityManager->persist($template);
         }
         $template->fromArray($data);
         if (!$template->getId() || $settings->getReloadSnippets()) {
             $this->synchronizeSnippets($template);
         }
         $this->entityManager->flush($template);
         $themes[] = $theme;
     }
     return $themes;
 }