Returns a list of entities.

@param \Symfony\Component\HttpFoundation\Request $request
@param array $filters
@param bool $addPagination
@return array
551177
public function findEntities(Request $request, $filters = array(), $addPagination = false)
    {
        $options = $this->getOptions($request, $filters, $addPagination);
        if (!$addPagination) {
            return array(
                'entities' => $this->getRepository()->getEntities($options),
                'options' => $options
            );
        }

        $entities = $this->getRepository()->getPaginatedEntities($options);
        $options['elements'] = $entities->count();
        $options['pages'] = (int)ceil($options['elements'] / $options['elementsPerPage']);

        return array(
            'entities' => $entities,
            'options' => $options
        );
    }
1166091
public function getServices($filter = null)
	{
		$services = array();

		// Create the request
		$request = new client\Request('/api/mpegts/service/grid');

		if ($filter)
			$request->setFilter($filter);

		// Get the response
		$response = $this->_client->getResponse($request);
		$rawContent = $response->getContent();

		$content = json_decode($rawContent);

		foreach ($content->entries as $entry)
			$services[] = model\Service::fromRawEntry($entry);

		return $services;
	}
1294124
public function getSuggestions(SearchRequest $searchRequest, array $additionalFilters = []) : array
    {
        $requestId = (int)$this->tsfe->getRequestedId();
        $groupList = (string)$this->tsfe->gr_list;

        $suggestQuery = $this->queryBuilder->buildSuggestQuery($searchRequest->getRawUserQuery(), $additionalFilters, $requestId, $groupList);
        $solrSuggestions = $this->getSolrSuggestions($suggestQuery);

        if ($solrSuggestions === []) {
            return ['status' => false];
        }

        $maxSuggestions = $this->typoScriptConfiguration->getSuggestNumberOfSuggestions();
        $showTopResults = $this->typoScriptConfiguration->getSuggestShowTopResults();
        $suggestions    = $this->getSuggestionArray($suggestQuery, $solrSuggestions, $maxSuggestions);

        if (!$showTopResults) {
            return $this->getResultArray($searchRequest, $suggestions, [], false);
        }

        return $this->addTopResultsToSuggestions($searchRequest, $suggestions, $additionalFilters);
    }
241867
public function convert(AbstractPaginationQuery $filter, ArrayAccess $response)
    {
        $entities = [];
        $ids = [];
        $return = [];

        if (!isset($response['response'])
            || !isset($response['response']['docs'])
            || !is_array($response['response']['docs'])) {
            throw new InvalidArgumentException('invalid response');
        }
        
        foreach ($response['response']['docs'] as $doc) {
            $ids[] = $doc->id;
        }

        // fetch entities with given IDs
        $repository = $this->repositories->get($filter->getRepositoryName());
        $qb = $repository->createQueryBuilder() /* @var $repository \Core\Repository\AbstractRepository */
            ->field('id')
            ->in($ids);
        $result = $qb->getQuery()->execute();
        
        foreach ($result as $document) {
            $entities[$document->getId()] = $document;
        }
        
        // iterate over Solr response to preserve sorting
        foreach ($response['response']['docs'] as $doc) {
            $entity = isset($entities[$doc->id]) ? $entities[$doc->id] : $repository->create();
            $return[] = $filter->proxyFactory($entity, $doc);
        }
        
        return $return;
    }
755908
public function retrieveAll(array $filters = array(), $limit = null, $offset = null)
    {
        $result = clone $this->entityCollection;
        if (!empty($filters)) {
            $result = $result->search($filters);
        }
        if ($offset) {
            $result = $result->cslice($offset, $limit);
        }
        if ($limit && !$offset) {
            $result = $result->chunk($limit);
        }

        return $result;
    }
1074729
protected function getFilters(Request $request)
    {
        $type = $this->getFilterType($request);

        if (!$type) {
            return $request->query->get('search')['value'];
        }

        $filter = new $type();

        $param = $filter->getBlockPrefix();

        return $request->query->get($param);
    }
753024
public function listResources($filter)
    {
        $alias = 'resource';
        $collection = $this->getThisCollection();

        $queryBuilder = $this->getRepository()
            ->createQueryBuilder($alias);

        // Build the filter on resources
        $this->filterQueryBuilder($queryBuilder, $filter, $collection, $alias);

        // Count the total number of resources
        $countQueryBuilder = clone $queryBuilder;
        $collectionIdentifier = $collection->getIdentifier();
        $totalNumberOfRows = $countQueryBuilder
            ->select($countQueryBuilder->expr()->count($alias . '.' . $collectionIdentifier))
            ->getQuery()
            ->getSingleScalarResult();

        // Paginate resources
        $this->paginateQueryBuilder($queryBuilder, $filter);

        // Finally, select all fields
        $queryBuilder->select($alias);

        $returnedResources = $this->loadResourcesFromQueryBuilder($queryBuilder, $this->getThisCollection());

        return Resource::formatResourcesJsonApi($returnedResources, $totalNumberOfRows);
    }
458676
public function addFilters(array $filters)
    {
        foreach ($filters as $filter) {
            if ($filter instanceof QueryDSL) {
                $this->addFilter($filter);
            }
        }
        return $this;
    }
881504
public function listResources($filter)
    {
        $collection = $this->getThisCollection();

        $queryBuilder = $this->filterQueryBuilder($filter, $collection);

        $countQueryBuilder = clone $queryBuilder;
        $countQueryBuilder->orders = null;
        $totalNumberOfRows = $countQueryBuilder->count();

        // Paginate resources
        $this->paginateQueryBuilder($queryBuilder, $filter);

        $returnedResources = $this->loadResourcesFromQueryBuilder($queryBuilder, $this->getThisCollection());

        return ForestResource::formatResourcesJsonApi($returnedResources, $totalNumberOfRows);
    }
56872
public function getFilters(Request $request, $overrideFilters = array(), $ignoreSession = false)
    {
        if ($ignoreSession) {
            return array_replace(
                $this->getFiltersFromRequest($request),
                $overrideFilters
            );
        }

        $filters = array_replace(
            $this->getFiltersFromSession($request->getSession()),
            $this->getFiltersFromRequest($request),
            $overrideFilters
        );

        $this->saveFilters($request->getSession(), $filters);
        return $filters;
    }
523034
private function getList(Request $request, $locale)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->getRestHelper();

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        $listBuilder = $factory->create($this->container->getParameter('sulu.model.contact.class'));
        $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors());

        $listResponse = $this->prepareListResponse($listBuilder, $locale);

        return new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'get_contacts',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );
    }
1263956
public function list(array $filters = [])
    {
        return $this->curl->get($this->base_url.'?'.http_build_query([
                    'filters' => json_encode($filters),
                ]
            )
        );
    }
1003458
public function listAction(Request $request)
    {
        $query = $this->addOrganizationFilter($request->query->all());

        return new JsonResponse($this->finder->search(
            $this->getClass(),
            $query,
            []
        ));
    }
971168
public static function findFirst(Filter ...$filters)
    {
        $results = static::find(...$filters);

        if (sizeof($results) == 0) {
            throw new RecordNotFoundException(get_called_class(), 0);
        }

        return $results[0];
    }
759214
public function indexAction(Request $request)
    {
        $page = $request->get("page", 1);
        $em = $this->getDoctrine()->getManager();

        $filter = [
            'q' => $request->get('q'),
            'category' => $request->get('filter_category'),
            'is_enabled' => $request->get('is_enabled', true),
        ];

        $qb = $em->getRepository(Product::class)->findAllFilteredQB($filter);

        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate($qb, $page, 40);

        return array(
            'pagination' => $pagination,
            'filter' => $filter,
        );
    }
218035
public function findBy($filters, $pageOpts = array(), $sort = array(), $inDeleted = false)
    {
        $qb = $this->db->createQueryBuilder();

        $qb->select($this->getSelect($this->profile))
            ->from($this->table, 't')
            ->where('1 = 1');

        $this->addJoins($qb, $this->getJoins($this->profile));
        $params = $this->addFilters($qb, $this->getFilters($this->profile));
        $params = array_merge($params, $this->addFilters($qb, $filters));
        $this->addGrouping($qb, $this->getGroupings($this->profile));
        $this->addSort($qb, $sort);

        return $this->getAll($qb, $params, $pageOpts, $inDeleted);
    }
467651
public function invoke(FilterableServiceInterface $service, $perPageCount, array $parameters = array())
    {
        $page = $this->getPageNumber();
        $sort = $this->getSortingColumn();
        $desc = $this->getDesc();

        $records = $service->filter($this->getData(), $page, $perPageCount, $sort, $desc, $parameters);

        // Tweak pagination if available
        if (method_exists($service, 'getPaginator')) {
            $paginator = $service->getPaginator();

            if ($paginator instanceof PaginatorInterface) {
                $paginator->setUrl($this->getPaginationUrl($page, $sort, $desc));
            }
        }

        return $records;
    }