Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php
public function findByProperties($term, $nodeTypeFilter, $workspace, $dimensions, $pathStartingPoint = null)
    {
        if (empty($term)) {
            throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
        }
        $workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);

        $queryBuilder = $this->createQueryBuilder($workspaces);
        $this->addDimensionJoinConstraintsToQueryBuilder($queryBuilder, $dimensions);
        $this->addNodeTypeFilterConstraintsToQueryBuilder($queryBuilder, $nodeTypeFilter);

        if (is_array($term)) {
            if (count($term) !== 1) {
                throw new \InvalidArgumentException('Currently only a 1-dimensional key => value array term is supported.', 1460437584);
            }

            // Build the like parameter as "key": "value" to search by a specific key and value
            $likeParameter = '%' . UnicodeFunctions::strtolower(trim(json_encode($term, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE), "{}\n\t ")) . '%';
        } else {
            // Convert to lowercase, then to json, and then trim quotes from json to have valid JSON escaping.
            $likeParameter = '%' . trim(json_encode(UnicodeFunctions::strtolower($term), JSON_UNESCAPED_UNICODE), '"') . '%';
        }

        $queryBuilder->andWhere("LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :term")->setParameter('term', $likeParameter);

        if (strlen($pathStartingPoint) > 0) {
            $pathStartingPoint = strtolower($pathStartingPoint);
            $queryBuilder->andWhere(
                $queryBuilder->expr()->orx()
                    ->add($queryBuilder->expr()->eq('n.parentPathHash', ':parentPathHash'))
                    ->add($queryBuilder->expr()->eq('n.pathHash', ':pathHash'))
                    ->add($queryBuilder->expr()->like('n.parentPath', ':parentPath')))
                ->setParameter('parentPathHash', md5($pathStartingPoint))
                ->setParameter('pathHash', md5($pathStartingPoint))
                ->setParameter('parentPath', rtrim($pathStartingPoint, '/') . '/%');
        }

        $query = $queryBuilder->getQuery();
        $foundNodes = $query->getResult();
        $foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($foundNodes, $workspaces, $dimensions);
        $foundNodes = $this->withoutRemovedNodes($foundNodes);

        return $foundNodes;
    }
public function findByProperties($term, $nodeTypeFilter, $workspace, $dimensions, $pathStartingPoint = null)
    {
        if (empty($term)) {
            throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
        }
        $workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);

        $queryBuilder = $this->createQueryBuilder($workspaces);
        $this->addDimensionJoinConstraintsToQueryBuilder($queryBuilder, $dimensions);
        $this->addNodeTypeFilterConstraintsToQueryBuilder($queryBuilder, $nodeTypeFilter);

        if (is_array($term)) {
            if (count($term) !== 1) {
                throw new \InvalidArgumentException('Currently only a 1-dimensional key => value array term is supported.', 1460437584);
            }

            // Build the like parameter as "key": "value" to search by a specific key and value
            $likeParameter = '%' . UnicodeFunctions::strtolower(trim(json_encode($term, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE), "{}\n\t ")) . '%';
        } else {
            // Convert to lowercase, then to json, and then trim quotes from json to have valid JSON escaping.
            $likeParameter = '%' . trim(json_encode(UnicodeFunctions::strtolower($term), JSON_UNESCAPED_UNICODE), '"') . '%';
        }

        $queryBuilder->andWhere("LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :term")->setParameter('term', $likeParameter);

        if (strlen($pathStartingPoint) > 0) {
            $pathStartingPoint = strtolower($pathStartingPoint);
            $queryBuilder->andWhere(
                $queryBuilder->expr()->orx()
                    ->add($queryBuilder->expr()->eq('n.parentPathHash', ':parentPathHash'))
                    ->add($queryBuilder->expr()->eq('n.pathHash', ':pathHash'))
                    ->add($queryBuilder->expr()->like('n.parentPath', ':parentPath')))
                ->setParameter('parentPathHash', md5($pathStartingPoint))
                ->setParameter('pathHash', md5($pathStartingPoint))
                ->setParameter('parentPath', rtrim($pathStartingPoint, '/') . '/%');
        }

        $query = $queryBuilder->getQuery();
        $foundNodes = $query->getResult();
        $foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($foundNodes, $workspaces, $dimensions);
        $foundNodes = $this->withoutRemovedNodes($foundNodes);

        return $foundNodes;
    }
public function findByProperties ( $ term , $ nodeTypeFilter , $ workspace , $ dimensions , $ pathStartingPoint = null ) { if ( empty ( $ term ) ) { throw new \ InvalidArgumentException ( '"term" cannot be empty: provide a term to search for.' , 1421329285 ) ; } $ workspaces = $ this -> collectWorkspaceAndAllBaseWorkspaces ( $ workspace ) ; $ queryBuilder = $ this -> createQueryBuilder ( $ workspaces ) ; $ this -> addDimensionJoinConstraintsToQueryBuilder ( $ queryBuilder , $ dimensions ) ; $ this -> addNodeTypeFilterConstraintsToQueryBuilder ( $ queryBuilder , $ nodeTypeFilter ) ; if ( is_array ( $ term ) ) { if ( count ( $ term ) !== 1 ) { throw new \ InvalidArgumentException ( 'Currently only a 1-dimensional key => value array term is supported.' , 1460437584 ) ; } // Build the like parameter as "key": "value" to search by a specific key and value $ likeParameter = '%' . UnicodeFunctions :: strtolower ( trim ( json_encode ( $ term , JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE ) , "{}\n\t " ) ) . '%' ; } else { // Convert to lowercase, then to json, and then trim quotes from json to have valid JSON escaping. $ likeParameter = '%' . trim ( json_encode ( UnicodeFunctions :: strtolower ( $ term ) , JSON_UNESCAPED_UNICODE ) , '"' ) . '%' ; } $ queryBuilder -> andWhere ( "LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :term" ) -> setParameter ( 'term' , $ likeParameter ) ; if ( strlen ( $ pathStartingPoint ) > 0 ) { $ pathStartingPoint = strtolower ( $ pathStartingPoint ) ; $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> orx ( ) -> add ( $ queryBuilder -> expr ( ) -> eq ( 'n.parentPathHash' , ':parentPathHash' ) ) -> add ( $ queryBuilder -> expr ( ) -> eq ( 'n.pathHash' , ':pathHash' ) ) -> add ( $ queryBuilder -> expr ( ) -> like ( 'n.parentPath' , ':parentPath' ) ) ) -> setParameter ( 'parentPathHash' , md5 ( $ pathStartingPoint ) ) -> setParameter ( 'pathHash' , md5 ( $ pathStartingPoint ) ) -> setParameter ( 'parentPath' , rtrim ( $ pathStartingPoint , '/' ) . '/%' ) ; } $ query = $ queryBuilder -> getQuery ( ) ; $ foundNodes = $ query -> getResult ( ) ; $ foundNodes = $ this -> reduceNodeVariantsByWorkspacesAndDimensions ( $ foundNodes , $ workspaces , $ dimensions ) ; $ foundNodes = $ this -> withoutRemovedNodes ( $ foundNodes ) ; return $ foundNodes ; }
Find nodes by a value in properties

This method is internal and will be replaced with better search capabilities.

@param string|array $term Search term
@param string $nodeTypeFilter Node type filter
@param Workspace $workspace
@param array $dimensions
@param string $pathStartingPoint
@return array<\Neos\ContentRepository\Domain\Model\NodeData>
Find nodes by a value in properties