/**
  * Get all childs of a given node
  *
  * @param Node $node
  *
  * @return array
  */
 public function getChildren(Node $node)
 {
     return $this->findBy(array('parent' => $node->getId()), array('weight' => 'ASC'));
 }
 /**
  * @param Node   $parentNode The parent node (may be null)
  * @param string $slug       The slug
  *
  * @return Node|null
  */
 public function getNodeForSlug(Node $parentNode, $slug)
 {
     $slugParts = explode("/", $slug);
     $result = null;
     foreach ($slugParts as $slugPart) {
         if ($parentNode) {
             if ($r = $this->findOneBy(array('slug' => $slugPart, 'parent.parent' => $parentNode->getId()))) {
                 $result = $r;
             }
         } else {
             if ($r = $this->findOneBy(array('slug' => $slugPart))) {
                 $result = $r;
             }
         }
     }
     return $result;
 }
 /**
  * @param Node $node
  * @param bool $includeHiddenFromNav
  *
  * @return NodeMenuItem[]
  */
 public function getChildren(Node $node, $includeHiddenFromNav = true)
 {
     $children = array();
     if (array_key_exists($node->getId(), $this->childNodes)) {
         $nodes = $this->childNodes[$node->getId()];
         /* @var Node $childNode */
         foreach ($nodes as $childNode) {
             $nodeTranslation = $childNode->getNodeTranslation($this->lang, $this->includeOffline);
             if (!is_null($nodeTranslation)) {
                 $children[] = new NodeMenuItem($childNode, $nodeTranslation, false, $this);
             }
         }
         $children = array_filter($children, function (NodeMenuItem $entry) use($includeHiddenFromNav) {
             if ($entry->getNode()->isHiddenFromNav() && !$includeHiddenFromNav) {
                 return false;
             }
             return true;
         });
     }
     return $children;
 }
 /**
  * Create a search document for a page
  *
  * @param NodeTranslation  $nodeTranslation
  * @param Node             $node
  * @param NodeVersion      $publicNodeVersion
  * @param HasNodeInterface $page
  */
 protected function addPageToIndex(NodeTranslation $nodeTranslation, Node $node, NodeVersion $publicNodeVersion, HasNodeInterface $page)
 {
     $doc = array('node_id' => $node->getId(), 'node_translation_id' => $nodeTranslation->getId(), 'node_version_id' => $publicNodeVersion->getId(), 'title' => $nodeTranslation->getTitle(), 'lang' => $nodeTranslation->getLang(), 'slug' => $nodeTranslation->getFullSlug(), 'page_class' => ClassLookup::getClass($page), 'created' => $this->getUTCDateTime($nodeTranslation->getCreated())->format(\DateTime::ISO8601), 'updated' => $this->getUTCDateTime($nodeTranslation->getUpdated())->format(\DateTime::ISO8601));
     if ($this->logger) {
         $this->logger->info('Indexing document : ' . implode(', ', $doc));
     }
     // Permissions
     $this->addPermissions($node, $doc);
     // Search type
     $this->addSearchType($page, $doc);
     // Analyzer field
     $this->addAnalyzer($nodeTranslation, $doc);
     // Parent and Ancestors
     $this->addParentAndAncestors($node, $doc);
     // Content
     $this->addPageContent($nodeTranslation, $page, $doc);
     // Add document to index
     $uid = 'nodetranslation_' . $nodeTranslation->getId();
     $this->addBoost($node, $page, $doc);
     $this->addCustomData($page, $doc);
     $this->documents[] = $this->searchProvider->createDocument($uid, $doc, $this->indexName, $this->indexType . '_' . $nodeTranslation->getLang());
 }
예제 #5
0
 /**
  * @return int
  */
 public function getId()
 {
     return $this->node->getId();
 }