コード例 #1
0
 /**
  * Move a section page as sibling of $target.
  *
  * @param  Page                 $page               The page to be moved.
  * @param  Page                 $target             The target page.
  * @param  boolean              $asPrevious         Move page as previous sibling of $target if true (default), next sibling elsewhere.
  *
  * @return Page                                     The moved page.
  */
 private function moveSectionAsSiblingOf(Page $page, Page $target, $asPrevious = true)
 {
     $delta = $page->getLevel() - $target->getLevel();
     $this->shiftLevel($page, $delta);
     $this->getEntityManager()->getRepository('BackBee\\CoreDomain\\NestedNode\\Section')->moveNode($page->getSection(), $target->getSection(), $asPrevious ? 'before' : 'after');
     return $page;
 }
コード例 #2
0
 /**
  * Add query part to select siblings of page.
  *
  * @param  Page                 $page               The page to look for siblings
  * @param  boolean              $strict             Optional, if false (by default) $node is include to the selection
  * @param  array|null           $order              Optional, ordering spec ( [$field => $sort] )
  * @param  integer|null         $limit              Optional, max number of results, if null no limit
  * @param  integer              $start              Optional, first result index (0 by default)
  *
  * @return PageQueryBuilder
  */
 public function andIsSiblingsOf(Page $page, $strict = false, array $order = null, $limit = null, $start = 0)
 {
     if (null === $page->getParent()) {
         $this->andParentIs(null);
     } else {
         $this->andIsDescendantOf($page->getParent(), false, $page->getLevel());
     }
     if (true === $strict) {
         $suffix = $this->getSuffix();
         $this->andWhere($this->getAlias() . ' != :page' . $suffix)->setParameter('page' . $suffix, $page);
     }
     if (null !== $order) {
         $this->addMultipleOrderBy($order);
     }
     if (null !== $limit) {
         $this->setMaxResults($limit)->setFirstResult($start);
     }
     return $this;
 }