예제 #1
0
 /**
  * Add layout for specific media.
  * 
  * @param string $media
  * @param ThemeLayoutInterface $layout
  * @return TemplateLayout
  */
 public function addLayout($media, ThemeLayoutInterface $layout)
 {
     $templateLayout = new TemplateLayout($media);
     $templateLayout->setLayoutName($layout->getName());
     $templateLayout->setTemplate($this);
     return $templateLayout;
 }
예제 #2
0
 protected function createEntityTemplate($data)
 {
     $template = new Template();
     $this->em->persist($template);
     $layout = new TemplateLayout($data['media']);
     $layout->setLayoutName($data['layoutName']);
     $layout->setTemplate($template);
     $this->em->persist($layout);
     foreach ($data['localizations'] as $locale => $title) {
         $localization = new TemplateLocalization($locale);
         $localization->setTitle($title);
         $localization->setTemplate($template);
         $this->em->persist($localization);
     }
     return $template;
 }
 protected function prepareData(ClassMetadata $metadata, array $data)
 {
     foreach ($data as $name => &$entityData) {
         switch ($metadata->name) {
             case Localization::CN():
             case PageLocalization::CN():
             case TemplateLocalization::CN():
             case ApplicationLocalization::CN():
                 $entityData['publishedRevision'] = null;
                 $args = array($entityData['locale']);
                 break;
             case PageLocalizationPath::CN():
                 $args = array(str_ireplace('pageLocalizationPath', '', $name), $entityData['locale']);
                 break;
             case TemplateLayout::CN():
                 $args = array($entityData['media']);
                 break;
             case BlockPropertyMetadata::CN():
                 $args = array($entityData['name'], $entityData['blockProperty']);
                 break;
             case BlockProperty::CN():
                 $args = array($entityData['name']);
                 break;
             case PagePlaceHolder::CN():
             case TemplatePlaceHolder::CN():
                 $args = array($entityData['name']);
                 break;
             default:
                 $constructor = new \ReflectionMethod($metadata->name, '__construct');
                 if ($constructor->getNumberOfRequiredParameters() === 0) {
                     return parent::prepareData($metadata, $data);
                 }
                 throw new \RuntimeException(sprintf('Don\'t know how to build constructor required for [%s].', $metadata->name));
         }
         $entityData = array_merge(array('__construct' => $args), $entityData);
     }
     return parent::prepareData($metadata, $data);
 }