Example #1
0
 /**
  * Returns the built page instance.
  *
  * @return Page                                     The built page.
  */
 public function getPage()
 {
     if (null === $this->site || null === $this->layout || null === $this->title) {
         $this->reset();
         throw new \Exception("Required data missing");
     }
     $page = new Page($this->uid);
     $page->setTitle($this->title);
     $page->setSite($this->site);
     if (null !== $this->parent) {
         $page->setParent($this->insureParentIsSection($this->parent));
     }
     $page->setLayout($this->layout, $this->itemToPushInMainZone);
     if (null !== $this->url) {
         $page->setUrl($this->url);
     }
     if (null !== $this->redirect) {
         $page->setRedirect($this->redirect);
     }
     if (null !== $this->target) {
         $page->setTarget($this->target);
     }
     if (null !== $this->altTitle) {
         $page->setAltTitle($this->altTitle);
     }
     if (null !== $this->state) {
         $page->setState($this->state);
     }
     if (null !== $this->publishedAt) {
         $page->setPublishing($this->publishedAt);
     }
     if (null !== $this->createdAt) {
         $page->setCreated($this->createdAt);
     }
     if (null !== $this->archiving) {
         $page->setArchiving($this->archiving);
     }
     $pageContentSet = $page->getContentSet();
     $this->updateContentRevision($pageContentSet);
     while ($column = $pageContentSet->next()) {
         $this->updateContentRevision($column);
     }
     if (0 < count($this->elements)) {
         foreach ($this->elements as $e) {
             $column = $pageContentSet->item($e['content_set_position']);
             if ($e['set_main_node']) {
                 $e['content']->setMainNode($page);
             }
             $column->push($e['content']);
         }
         $pageContentSet->rewind();
     }
     $this->doPersistIfValid($page);
     $this->reset();
     return $page;
 }