Neos\Neos\Service\View\NodeView::assignFilteredChildNodes PHP Method

assignFilteredChildNodes() public method

Prepares this view to render a list or tree of filtered nodes.
public assignFilteredChildNodes ( Neos\ContentRepository\Domain\Model\NodeInterface $node, array $matchedNodes, integer $outputStyle = self::STYLE_LIST ) : void
$node Neos\ContentRepository\Domain\Model\NodeInterface
$matchedNodes array
$outputStyle integer Either STYLE_TREE or STYLE_list
return void
    public function assignFilteredChildNodes(NodeInterface $node, array $matchedNodes, $outputStyle = self::STYLE_LIST)
    {
        $this->outputStyle = $outputStyle;
        $nodes = $this->collectParentNodeData($node, $matchedNodes);
        $this->setConfiguration(array('value' => array('data' => array('_descendAll' => array()))));
        $this->assign('value', array('data' => $nodes, 'success' => true));
    }

Usage Example

Example #1
0
 /**
  * Return child nodes of specified node for usage in a TreeLoader based on filter
  *
  * @param Node $node The node to find child nodes for
  * @param string $term
  * @param string $nodeType
  * @return void
  */
 public function filterChildNodesForTreeAction(Node $node, $term, $nodeType)
 {
     $nodeTypes = strlen($nodeType) > 0 ? array($nodeType) : array_keys($this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document', false));
     $context = $node->getContext();
     if ($term !== '') {
         $nodes = $this->nodeSearchService->findByProperties($term, $nodeTypes, $context, $node);
     } else {
         $nodes = array();
         $nodeDataRecords = $this->nodeDataRepository->findByParentAndNodeTypeRecursively($node->getPath(), implode(',', $nodeTypes), $context->getWorkspace(), $context->getDimensions());
         foreach ($nodeDataRecords as $nodeData) {
             $matchedNode = $this->nodeFactory->createFromNodeData($nodeData, $context);
             if ($matchedNode !== null) {
                 $nodes[$matchedNode->getPath()] = $matchedNode;
             }
         }
     }
     $this->view->assignFilteredChildNodes($node, $nodes);
 }