Example #1
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;
 }
Example #2
0
 /**
  * Builds the configuration for the less compiler class.
  *
  * @param \Shopware\Models\Shop\Shop $shop
  * @return array
  */
 private function getCompilerConfiguration(Shop\Shop $shop)
 {
     $settings = $this->service->getSystemConfiguration(AbstractQuery::HYDRATE_OBJECT);
     $config = array('compress' => $settings->getCompressCss(), 'sourceMap' => $settings->getCreateSourceMap());
     if ($settings->getCreateSourceMap()) {
         $config += array('sourceMapWriteTo' => $this->pathResolver->getSourceMapPath(), 'sourceMapURL' => $this->pathResolver->getSourceMapUrl($shop));
     }
     $config = $this->eventManager->filter('Theme_Compiler_Configure', $config, array('shop' => $shop, 'settings' => $settings));
     return $config;
 }