Neos\ContentRepository\Domain\Repository\NodeDataRepository::findByParentAndNodeTypeInContext PHP Method

findByParentAndNodeTypeInContext() public method

TODO Move to a new Node operation getDescendantNodes(...)
public findByParentAndNodeTypeInContext ( string $parentPath, string $nodeTypeFilter, Context $context, boolean $recursive = false ) : array<\Neos\ContentRepository\Domain\Model\NodeInterface>
$parentPath string Absolute path of the parent node
$nodeTypeFilter string Filter the node type of the nodes, allows complex expressions (e.g. "Neos.Neos:Page", "!Neos.Neos:Page,Neos.Neos:Text" or NULL)
$context Neos\ContentRepository\Domain\Service\Context The containing workspace
$recursive boolean If TRUE *all* matching nodes underneath the specified parent path are returned
return array<\Neos\ContentRepository\Domain\Model\NodeInterface>
    public function findByParentAndNodeTypeInContext($parentPath, $nodeTypeFilter, Context $context, $recursive = false)
    {
        $nodeDataElements = $this->findByParentAndNodeType($parentPath, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $context->isRemovedContentShown() ? null : false, $recursive);
        $finalNodes = [];
        foreach ($nodeDataElements as $nodeData) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
            if ($node !== null) {
                $finalNodes[] = $node;
            }
        }
        return $finalNodes;
    }

Usage Example

コード例 #1
0
 /**
  * Returns all direct child nodes of this node.
  * If a node type is specified, only nodes of that type are returned.
  *
  * @param string $nodeTypeFilter If specified, only nodes with that node type are considered
  * @param integer $limit An optional limit for the number of nodes to find. Added or removed nodes can still change the number nodes!
  * @param integer $offset An optional offset for the query
  * @return array<\Neos\ContentRepository\Domain\Model\NodeInterface> An array of nodes or an empty array if no child nodes matched
  * @api
  */
 public function getChildNodes($nodeTypeFilter = null, $limit = null, $offset = null)
 {
     $nodes = $this->context->getFirstLevelNodeCache()->getChildNodesByPathAndNodeTypeFilter($this->getPath(), $nodeTypeFilter);
     if ($nodes === false) {
         $nodes = $this->nodeDataRepository->findByParentAndNodeTypeInContext($this->getPath(), $nodeTypeFilter, $this->context, false);
         $this->context->getFirstLevelNodeCache()->setChildNodesByPathAndNodeTypeFilter($this->getPath(), $nodeTypeFilter, $nodes);
     }
     if ($offset !== null || $limit !== null) {
         $offset = $offset === null ? 0 : $offset;
         return array_slice($nodes, $offset, $limit);
     }
     return $nodes;
 }
All Usage Examples Of Neos\ContentRepository\Domain\Repository\NodeDataRepository::findByParentAndNodeTypeInContext