Neos\Neos\Domain\Service\NodeSearchService::findByProperties PHP Method

findByProperties() public method

TODO: Implement a better search when Flow offer the possibility
public findByProperties ( string | array $term, array $searchNodeTypes, Context $context, Neos\ContentRepository\Domain\Model\NodeInterface $startingPoint = null ) : array
$term string | array search term
$searchNodeTypes array
$context Neos\ContentRepository\Domain\Service\Context
$startingPoint Neos\ContentRepository\Domain\Model\NodeInterface
return array <\Neos\ContentRepository\Domain\Model\NodeInterface>
    public function findByProperties($term, array $searchNodeTypes, Context $context, NodeInterface $startingPoint = null)
    {
        if (empty($term)) {
            throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
        }
        $searchResult = array();
        $nodeTypeFilter = implode(',', $searchNodeTypes);
        $nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null);
        foreach ($nodeDataRecords as $nodeData) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
            if ($node !== null) {
                $searchResult[$node->getPath()] = $node;
            }
        }
        return $searchResult;
    }

Usage Example

 /**
  * Search a page, needed for internal links.
  *
  * @deprecated will be removed with 3.0, use Service/NodesController->indexAction() instead
  * @param string $query
  * @return void
  */
 public function searchPageAction($query)
 {
     $searchResult = array();
     $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document');
     /** @var NodeInterface $node */
     foreach ($this->nodeSearchService->findByProperties($query, $documentNodeTypes, $this->createContext('live')) as $node) {
         $searchResult[$node->getPath()] = $this->processNodeForEditorPlugins($node);
     }
     $this->view->assign('value', array('searchResult' => $searchResult, 'success' => true));
 }
All Usage Examples Of Neos\Neos\Domain\Service\NodeSearchService::findByProperties
NodeSearchService