Example #1
0
 /**
  * Sets the layout for the page.
  * Adds as much ContentSet to the page main ContentSet than defined zones in layout.
  *
  * @param  Layout               $layout
  * @param  AbstractClassContent $toPushInMainZone
  *
  * @return Page
  */
 public function setLayout(Layout $layout, AbstractClassContent $toPushInMainZone = null)
 {
     $this->_layout = $layout;
     $count = count($layout->getZones());
     // Add as much ContentSet to the page main ContentSet than defined zones in layout
     for ($i = $this->getContentSet()->count(); $i < $count; $i++) {
         // Do this case really exists ?
         if (null === ($zone = $layout->getZone($i))) {
             $this->getContentSet()->push(new ContentSet());
             continue;
         }
         // Create a new column
         $contentset = new ContentSet(null, $zone->options);
         if (null !== $toPushInMainZone && true === $zone->mainZone) {
             // Existing content push in the main zone
             $contentset->push($toPushInMainZone->setMainNode($this));
         } elseif ('inherited' === $zone->defaultClassContent) {
             // Inherited zone => same ContentSet than parent if exist
             $contentset = $this->getInheritedContent($i, $contentset);
         } elseif ($zone->defaultClassContent) {
             // New default content push
             $contentset->push($this->createNewDefaultContent('BackBee\\ClassContent\\' . $zone->defaultClassContent, $zone->mainZone));
         }
         $this->getContentSet()->push($contentset);
     }
     return $this;
 }
Example #2
0
 /**
  * Sets the main node value of $content to $page.
  * Recompute $content if need.
  * 
  * @param AbstractClassContent $content
  * @param Page                 $page
  */
 private function setMainNode(AbstractClassContent $content, Page $page)
 {
     if (null !== $content->getMainNode()) {
         return;
     }
     $content->setMainNode($page);
     if (null !== $this->entityManager) {
         $uow = $this->entityManager->getUnitOfWork();
         $meta = $this->entityManager->getClassMetadata(get_class($content));
         if ($uow->isEntityScheduled($content)) {
             $uow->recomputeSingleEntityChangeSet($meta, $content);
         } elseif ($uow->isEntityScheduled($page)) {
             $uow->computeChangeSet($meta, $content);
         }
     }
 }