Exemplo n.º 1
0
 /**
  * Selects and save the theme to use for the given site. If site argument
  * is omitted, it will define the default theme to use.
  *
  * @param  string    $name
  * @param  Site|null $site
  * @return array
  */
 public function selectTheme($name, Site $site = null)
 {
     if (!isset($this->settings['options']) || !is_array($this->settings['options']) || !array_key_exists($name, $this->settings['options'])) {
         throw new \LogicException("Cannot select `{$name}` theme because it does not exist.");
     }
     $registry = $this->getThemeRegistry($site);
     if (null === $registry || null !== $site && null !== $registry && 'default' === $registry->getKey()) {
         $registry = new Registry();
         $registry->setKey($site ? $site->getLabel() : 'default');
         $registry->setType('selected_theme');
         $registry->setScope('THEME_CONFIG');
         $this->app->getEntityManager()->persist($registry);
     }
     $registry->setValue($name);
     $this->app->getEntityManager()->flush($registry);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Automatique registry builder from the current entity object.
  */
 private function buildRegistryFromObject()
 {
     if (!$this->entity instanceof DomainObjectInterface) {
         throw new \Exception('EntityRegistry have to implement DomainObjectInterface', 1);
     }
     $this->classname = get_class($this->entity);
     $identifier = new Registry();
     $this->registries[] = $identifier->setType($this->classname)->setKey('identifier')->setValue($this->entity->getObjectIdentifier());
     foreach ($this->entity->getObjectProperties() as $key => $value) {
         $registry = new Registry();
         $this->registries[] = $registry->setType($this->classname)->setKey($key)->setValue($value)->setScope($this->entity->getObjectIdentifier());
     }
 }