コード例 #1
0
 /**
  * Persist a new node or detach it from tree if already exists.
  *
  * @param  \BackBee\CoreDomain\NestedNode\AbstractNestedNode                     $node
  * @return \BackBee\CoreDomain\NestedNode\Repository\NestedNodeRepository
  */
 protected function detachOrPersistNode(AbstractNestedNode $node)
 {
     if (null !== ($refreshed = $this->find($node->getUid()))) {
         return $this->detachFromTree($refreshed)->refreshExistingNode($node);
     }
     if (false === $this->_em->contains($node)) {
         $this->_em->persist($node);
     }
     return $this;
 }
コード例 #2
0
 /**
  * Add query part to select descendants of $node.
  *
  * @param  \BackBee\CoreDomain\NestedNode\AbstractNestedNode                       $node
  * @param  boolean                                               $strict   If TRUE, $node is excluded from the selection
  * @param  int                                                   $at_level Filter ancestors by their level
  * @param  string                                                $alias    optional, the alias to use
  * @return \BackBee\NestedNode\Repository\NestedNodeQueryBuilder
  */
 public function andIsDescendantOf(AbstractNestedNode $node, $strict = false, $at_level = null, $alias = null)
 {
     $this->andRootIs($node->getRoot(), $alias)->andLeftnodeIsUpperThan($node->getLeftnode(), $strict, $alias)->andRightnodeIsLowerThan($node->getRightnode(), $strict, $alias);
     if (null !== $at_level) {
         $this->andLevelEquals($at_level);
     }
     return $this;
 }
コード例 #3
0
ファイル: Section.php プロジェクト: ReissClothing/BackBee
 /**
  * Class constructor.
  *
  * @param  string|null          $uid                The unique identifier of the section.
  * @param  array|null           $options            Initial options for the section:
  *                                                              - page      the associated page
  *                                                              - site      the owning site
  */
 public function __construct($uid = null, $options = null)
 {
     parent::__construct($uid, $options);
     if (is_array($options) && array_key_exists('page', $options) && $options['page'] instanceof Page) {
         $this->setPage($options['page']);
     } else {
         $this->setPage(new Page($this->getUid(), ['title' => 'Untitled', 'main_section' => $this]));
     }
     if (is_array($options) && array_key_exists('site', $options) && $options['site'] instanceof Site) {
         $this->setSite($options['site']);
     }
     $this->_pages = new ArrayCollection();
 }
コード例 #4
0
 /**
  * Is this node is a descendant of the provided one ?
  *
  * @param  \BackBee\CoreDomain\NestedNode\AbstractNestedNode $node
  * @param  Boolean                         $strict Optional, if TRUE (default) this node is excluded of descendants list
  *
  * @return Boolean                         TRUE if this node is a descendant or provided node, FALSE otherwise
  */
 public function isDescendantOf(AbstractNestedNode $node, $strict = true)
 {
     if (true === $strict) {
         return $this->getLeftnode() > $node->getLeftnode() && $this->getRightnode() < $node->getRightnode() && $this->getRoot() === $node->getRoot();
     } else {
         return $this->getLeftnode() >= $node->getLeftnode() && $this->getRightnode() <= $node->getRightnode() && $this->getRoot() === $node->getRoot();
     }
 }
コード例 #5
0
ファイル: KeyWord.php プロジェクト: ReissClothing/BackBee
 /**
  * Class constructor.
  *
  * @param string $uid The unique identifier of the keyword
  */
 public function __construct($uid = null)
 {
     parent::__construct($uid);
     $this->_content = new ArrayCollection();
 }