/** * Persist a new node or detach it from tree if already exists. * * @param \BackBee\NestedNode\AbstractNestedNode $node * @return \BackBee\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; }
/** * Add query part to select descendants of $node. * * @param \BackBee\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; }
/** * Is this node is a descendant of the provided one ? * * @param \BackBee\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(); } }
/** * 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(); }
/** * Class constructor. * * @param string $uid * @param string $title * @param string $url */ public function __construct($uid = null, $title = null, $url = null) { parent::__construct($uid); $this->_title = is_null($title) ? 'Untitled media folder' : $title; $this->_url = is_null($url) ? 'Url' : $url; $this->_medias = new ArrayCollection(); }
/** * Class constructor. * * @param string $uid The unique identifier of the keyword */ public function __construct($uid = null) { parent::__construct($uid); $this->_content = new ArrayCollection(); }