<?php use eZ\Publish\API\Repository\Values\Content\Query; use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd; use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LocationId; use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Visibility; /** @var string|int $locationBId */ /** @var \eZ\Publish\API\Repository\Repository $repository */ $searchService = $repository->getSearchService(); $query = new Query( array( 'filter' => new LogicalAnd( array( new LocationId( $locationBId ), new Visibility( Visibility::VISIBLE ), ) ) ) ); $searchResult = $searchService->findContent( $query ); // Content is found $content = $searchResult->searchHits[0]; |