/**
  * {@inheritDoc}
  */
 public function getConfigSets()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getConfigSets', array());
     return parent::getConfigSets();
 }
Example #2
0
 /**
  * Synchronize the theme configuration sets of the file system and
  * the database.
  *
  * @param Theme $theme
  * @param Shop\Template $template
  * @throws \Exception
  */
 private function synchronizeSets(Theme $theme, Shop\Template $template)
 {
     $collection = new ArrayCollection();
     $theme->createConfigSets($collection);
     $synchronized = array();
     //iterates all configurations sets of the file system
     foreach ($collection as $item) {
         if (!$item instanceof ConfigSet) {
             throw new \Exception(sprintf("Theme %s adds a configuration set which isn't an instance of Shopware\\Components\\Theme\\ConfigSet.", $theme->getTemplate()));
         }
         $item->validate();
         //check if this set is already defined, to prevent auto increment in the database.
         $existing = $this->getExistingConfigSet($template->getConfigSets(), $item->getName());
         //if the set isn't defined, create a new one
         if (!$existing instanceof Shop\TemplateConfig\Set) {
             $existing = new Shop\TemplateConfig\Set();
             $template->getConfigSets()->add($existing);
         }
         $existing->setTemplate($template);
         $existing->setName($item->getName());
         $existing->setDescription($item->getDescription());
         $existing->setValues($item->getValues());
         $this->eventManager->notify('Theme_Configurator_Theme_ConfigSet_Updated', array('theme' => $theme, 'template' => $template, 'existing' => $existing, 'defined' => $item));
         $synchronized[] = $existing;
     }
     //iterates all sets of the template, file system and database
     foreach ($template->getConfigSets() as $existing) {
         //check if the current set was synchronized in the foreach before
         $defined = $this->getExistingConfigSet($synchronized, $existing->getName());
         if ($defined instanceof Shop\TemplateConfig\Set) {
             continue;
         }
         //if it wasn't synchronized, the file system theme want to remove the set.
         $this->entityManager->remove($existing);
     }
     $this->entityManager->flush();
     $this->eventManager->notify('Theme_Configurator_Theme_ConfigSets_Synchronized', array('theme' => $theme, 'template' => $template));
 }