/**
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  * @param $locale
  */
 public function createLayoutBlocks(ObjectManager $manager, $locale)
 {
     $textClass = false;
     $contentTypes = $this->container->getParameter('networking_init_cms.page.content_types');
     foreach ($contentTypes as $type) {
         if ($type['name'] == 'Text') {
             $textClass = $type['class'];
             break;
         }
     }
     if (!$textClass) {
         return;
     }
     $layoutBlock = new LayoutBlock();
     $layoutBlock->setIsActive(true);
     $layoutBlock->setSortOrder(1);
     $layoutBlock->setClassType($textClass);
     $layoutBlock->setZone($this->getFirstZone());
     $layoutBlock->setPage($this->getReference('homepage_' . $locale));
     $manager->persist($layoutBlock);
     $manager->flush();
     /** @var TextInterface  $text */
     $text = new $textClass();
     $text->setText('<h1>Hello World</h1><p>The locale of this page is ' . $locale . '</p>');
     $manager->persist($text);
     $manager->flush();
     $layoutBlock->setObjectId($text->getId());
     $manager->persist($layoutBlock);
     $manager->flush();
 }
Beispiel #2
0
 /**
  * @param LayoutBlock $layoutBlock
  * @return \Networking\InitCmsBundle\Model\PageInterface
  */
 public function getPageByLayoutBlock(LayoutBlock $layoutBlock)
 {
     return $layoutBlock->getPage();
 }