isSearchRequired example


    public function search(Criteria $criteria, SalesChannelContext $salesChannelContext): EntitySearchResult
    {
        $criteria = clone $criteria;

        $this->processCriteria($criteria$salesChannelContext);

        $aggregations = null;
        if ($criteria->getAggregations()) {
            $aggregations = $this->aggregate($criteria$salesChannelContext);
        }
        if (!RepositorySearchDetector::isSearchRequired($this->definition, $criteria)) {
            $entities = $this->read($criteria$salesChannelContext);

            return new EntitySearchResult($this->definition->getEntityName()$entities->count()$entities$aggregations$criteria$salesChannelContext->getContext());
        }

        $ids = $this->doSearch($criteria$salesChannelContext);

        if (empty($ids->getIds())) {
            /** @var TEntityCollection $collection */
            $collection = $this->definition->getCollectionClass();

            
/** * @return EntitySearchResult<TEntityCollection> */
    private function _search(Criteria $criteria, Context $context): EntitySearchResult
    {
        $criteria = clone $criteria;
        $aggregations = null;
        if ($criteria->getAggregations()) {
            $aggregations = $this->aggregate($criteria$context);
        }

        if (!RepositorySearchDetector::isSearchRequired($this->definition, $criteria)) {
            $this->eventDispatcher->dispatch(
                new EntitySearchedEvent($criteria$this->definition, $context)
            );
            $entities = $this->read($criteria$context);

            return new EntitySearchResult($this->definition->getEntityName()$entities->count()$entities$aggregations$criteria$context);
        }

        $ids = $this->searchIds($criteria$context);

        if (empty($ids->getIds())) {
            
Home | Imprint | This part of the site doesn't use cookies.