Esempio n. 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;
 }
Esempio n. 2
0
 public function testGetAction()
 {
     // create pages
     $now = new \DateTime();
     $homePage = new Page();
     $homePage->setTitle('Home Page')->setState(Page::STATE_ONLINE)->setSite($this->site)->setModified($now);
     $this->em->persist($homePage);
     $this->em->flush($homePage);
     $this->getAclManager()->insertOrUpdateObjectAce($homePage, new UserSecurityIdentity($this->group_id, 'BackBee\\Security\\Group'), MaskBuilder::MASK_VIEW);
     // no filters - should return current site root page
     $response = $this->sendRequest(self::requestGet('/rest/1/page/' . $homePage->getUid()));
     $this->assertTrue($response->isOk(), sprintf('HTTP 200 expected, HTTP %s returned.', $response->getStatusCode()));
     $pageProperties = json_decode($response->getContent(), true);
     $this->assertInternalType('array', $pageProperties);
     $this->assertCount(24, $pageProperties);
     $this->assertEquals($homePage->getUid(), $pageProperties['uid']);
     $this->assertEquals($now->getTimestamp(), $pageProperties['modified']);
 }
Esempio n. 3
0
 /**
  * @covers BackBee\NestedNode\Page::setTitle
  */
 public function testSetTitle()
 {
     $this->assertEquals($this->page, $this->page->setTitle('new-title'));
     $this->assertEquals('new-title', $this->page->getTitle());
 }
Esempio n. 4
0
 private function generatePage($title = 'backbee', $url = null, $doPersist = false)
 {
     $page = new Page();
     $page->setRoot($this->root);
     $page->setParent($this->root);
     $page->setTitle($title);
     $page->setUrl($url);
     if ($doPersist) {
         self::$em->persist($page);
         self::$em->flush($page);
     }
     return $page;
 }