Returns an unhydrated (ie. as associative array) list of entities.

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

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

        return array(
            'entities' => (array)$entities->getIterator(),
            'options' => $options
        );
    }
861802
public function buildSearch(SearchRequest $request, $filters = null)
    {
        $search = new Search();

        /** @var FilterInterface[] $filters */
        $filters = $filters ? $filters : $this->all();
        foreach ($filters as $name => $filter) {
            $filter->modifySearch($search, $request->get($name), $request);
        }

        return $search;
    }
1230614
public function listAction(Request $request)
    {
        $limit = $request->get('limit', 25);
        $start = $request->get('start', 0);
        $sort = $request->get('sort', 'createdAt');
        $dir = $request->get('dir', 'DESC');
        $filter = $request->get('filter', null);

        if ($filter) {
            $filter = json_decode($filter, true);
        }

        if (!is_array($filter)) {
            $filter = [];
        }

        $messageManager = $this->get('phlexible_message.message_manager');

        $priorityList = $messageManager->getPriorityNames();
        $typeList = $messageManager->getTypeNames();

        $priorityFilter = [];
        $typeFilter = [];
        $channelFilter = [];
        $roleFilter = [];

        $criteria = new Criteria();
        foreach ($filter as $key => $value) {
            if ($key === 'subject' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_SUBJECT_LIKE, $value);
            } elseif ($key === 'text' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_BODY_LIKE, $value);
            } elseif (substr($key, 0, 9) === 'priority_') {
                $priorityFilter[] = substr($key, 9);
            } elseif (substr($key, 0, 5) === 'type_') {
                $typeFilter[] = substr($key, 5);
            } elseif (substr($key, 0, 8) === 'channel_') {
                $channelFilter[] = substr($key, 8);
            } elseif (substr($key, 0, 5) === 'role_') {
                $roleFilter[] = substr($key, 9);
            } elseif ($key === 'date_after' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_START_DATE, $value);
            } elseif ($key === 'date_before' && !empty($value)) {
                $criteria->addRaw(Criteria::CRITERIUM_END_DATE, $value);
            }
        }

        if (count($priorityFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_PRIORITY_IN,
                implode(',', $priorityFilter)
            );
        }

        if (count($typeFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_TYPE_IN,
                implode(',', $typeFilter)
            );
        }

        if (count($channelFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_CHANNEL_IN,
                implode(',', $channelFilter)
            );
        }

        if (count($roleFilter)) {
            $criteria->addRaw(
                Criteria::CRITERIUM_ROLE_IN,
                implode(',', $roleFilter)
            );
        }

        $count = $messageManager->countByCriteria($criteria);
        $messages = $messageManager->findByCriteria($criteria, [$sort => $dir], $limit, $start);

        $data = [];
        foreach ($messages as $message) {
            $data[] = [
                'subject' => $message->getSubject(),
                'body' => nl2br($message->getBody()),
                'priority' => $priorityList[$message->getPriority()],
                'type' => $typeList[$message->getType()],
                'channel' => $message->getChannel(),
                'role' => $message->getRole(),
                'user' => $message->getUser(),
                'createdAt' => $message->getCreatedAt()->format('Y-m-d H:i:s'),
            ];
        }

        return new JsonResponse([
            'totalCount' => $count,
            'messages' => $data,
            'facets' => $messageManager->getFacetsByCriteria($criteria),
        ]);
    }
912573
public function selectAllPaginate(
        $first = 0,
        $max = 20,
        array $filters = [],
        array $orderBy = [],
        array $groupBy = [],
        $fetchJoinCollection = true
    ) {
        $selection = $this->getEntityManager()->createQueryBuilder();

        $selection->select([$this->entityAlias])
            ->from($this->entityClass, $this->entityAlias);

        $selection = $this->filterFurther($filters, $orderBy, $groupBy, $selection, $first, $max);

        return new Paginator($selection, $fetchJoinCollection);
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
357876
public function usersList(array $filter = [], $page = null, $limit = null)
    {
        $parameters = [];

        if (count($filter)) {
            $parameters['filter'] = $filter;
        }
        if (null !== $page) {
            $parameters['page'] = (int)$page;
        }
        if (null !== $limit) {
            $parameters['limit'] = (int)$limit;
        }

        /** @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            '/users',
            "GET",
            $parameters
        );
    }
1263956
public function list(array $filters = [])
    {
        return $this->curl->get($this->base_url.'?'.http_build_query([
                    'filters' => json_encode($filters),
                ]
            )
        );
    }
1271289
public function bindRequest(Request $request)
    {
        $query = $request->query;
        $session = $request->getSession();

        $adminListName = 'listconfig_'.$request->get('_route');

        $this->page = $request->query->getInt('page', 1);
        // Allow alphanumeric, _ & . in order by parameter!
        $this->orderBy = preg_replace('/[^[a-zA-Z0-9\_\.]]/', '', $request->query->get('orderBy', ''));
        $this->orderDirection = $request->query->getAlpha('orderDirection', '');

        // there is a session and the filter param is not set
        if ($session->has($adminListName) && !$query->has('filter')) {
            $adminListSessionData = $request->getSession()->get($adminListName);
            if (!$query->has('page')) {
                $this->page = $adminListSessionData['page'];
            }

            if (!$query->has('orderBy')) {
                $this->orderBy = $adminListSessionData['orderBy'];
            }

            if (!$query->has('orderDirection')) {
                $this->orderDirection = $adminListSessionData['orderDirection'];
            }
        }

        // save current parameters
        $session->set(
            $adminListName,
            array(
                'page' => $this->page,
                'orderBy' => $this->orderBy,
                'orderDirection' => $this->orderDirection,
            )
        );

        $this->getFilterBuilder()->bindRequest($request);
    }
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);
    }
968317
public function indexAction(Request $request)
    {
        /* init filters */
        $filter['q'] = $request->get('q');

        $em = $this->getDoctrine()->getManager();
        $qb = $em->getRepository('AmulenUserBundle:User')->createQueryBuilder('u');
        if ($filter['q']) {
            $qb->andWhere('(u.username LIKE :username OR u.email LIKE :username OR u.email LIKE :username OR u.firstname LIKE :username OR u.lastname LIKE :username)')->setParameter('username', '%' . $filter['q'] . '%');
        }

        $paginator = $this->get('knp_paginator')->paginate($qb, $request->query->get('page', 1), 20);

        return array(
            'paginator' => $paginator,
            'filter' => $filter,
        );
    }
217094
public function getList(Pagination $pagination = null, Filters $filters = null, $qParam = '')
    {
        $transfersList = new TransfersList($this->moip);

        return $transfersList->get($pagination, $filters, $qParam);
    }
242182
public function indexAction(Request $request)
    {
        $paginator = $this->get('opifer.content.content_manager')
            ->getPaginatedByRequest($request);

        $contents = $paginator->getCurrentPageResults();

        $contents = $this->get('jms_serializer')->serialize(iterator_to_array($contents), 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());

        $data = [
            'results'       => json_decode($contents, true),
            'total_results' => $paginator->getNbResults()
        ];

        return new JsonResponse($data);
    }
779170
public function indexAction(Request $request)
    {
        $this->checkIfUserHasPermission(Permission::VIEW);

        list($parentEntity, $association, $associationParam, $parentEntityId) = $this->getParentEntityDefinition($request);

        $this->getEventDispatcher()->dispatch(
            Events::PRE_CRUD_CONTROLLER_ACTION,
            new CrudControllerActionEvent($this->meta, __FUNCTION__)
        );

        $filterForm = $this->meta->isFilterFormEnabled()
            ? $this->getAdminFormFactory()->createFilterForm($this->meta, $associationParam, $parentEntityId)->handleRequest($request)
            : null;

        $qb = $this->getIndexQueryBuilder($request->getLocale(), !empty($filterForm) ? $filterForm->getData() : null);

        if ($this->getUserQueryBuilderFilterer()->isFilterable($qb)) {
            $this->getUserQueryBuilderFilterer()->filter($qb);
        }
        if ($this->meta->hasParent()) {
            $qb->andWhere(sprintf('o.%s = :%1$s', $association))->setParameter($association, $parentEntityId);
        }

        $paginatorOptions = [
            'wrap-queries' => true,
        ];

        $sortCriteria = $this->getSortCriteriaDetector()->detect($this->entityClass);

        if (!empty($sortCriteria)) {
            if ((count($sortCriteria) > 1 && !$request->query->has('sort')) || !$this->configuration['pagination']['enabled']) {
                foreach ($sortCriteria as $sort => $order) {
                    foreach (explode('+', $sort) as $part) {
                        if (false === strpos($part, '.')) {
                            $part = sprintf('o.%s', $part);
                        }

                        $qb->addOrderBy($part, $order);
                    }
                }
            } else {
                $sortField = array_keys($sortCriteria)[0];

                if (false === strpos($sortField, '.')) {
                    $sortField = sprintf('o.%s', $sortField);
                }

                $paginatorOptions['defaultSortFieldName'] = $sortField;
                $paginatorOptions['defaultSortDirection'] = reset($sortCriteria);
            }
        }

        $pagination = null;

        if ($this->configuration['pagination']['enabled']) {
            foreach (explode('+', $request->query->get('sort', '')) as $part) {
                $this->getSortedByEntityJoiner()->joinEntity($qb, $part, $request->getLocale());
            }

            $page = $request->query->get('page', 1);

            /** @var \Knp\Component\Pager\Pagination\AbstractPagination $pagination */
            $pagination = $this->getPaginator()->paginate($qb, $page, $this->configuration['pagination']['items'], $paginatorOptions);
            $entities = $page > 0 ? $pagination->getItems() : $qb->getQuery()->getResult();
            $entitiesCount = $pagination->getTotalItemCount();
        } else {
            $entities = $qb->getQuery()->getResult();
            $entitiesCount = count($entities);
        }
        if (isset($this->configuration['sorter'])) {
            $entities = $this->get($this->configuration['sorter']['id'])->{$this->configuration['sorter']['method']}($entities);
        }
        try {
            $this->getCustomObjectLoader()->loadCustomObjects($entities);
        } catch (CustomObjectException $ex) {
        }

        $batchDeleteForm = null;

        if (!empty($entities)
            && $this->isGranted(Permission::CREATE_DELETE, $this->entityClass)
            && $this->getAdminRouter()->isRouteExists($this->entityClass, AdminRouter::TYPE_BATCH_DELETE)
            && isset($this->configuration['view']['index']['action_widgets'][BatchDeleteWidget::ALIAS])
        ) {
            $batchDeleteForm = $this->getAdminFormFactory()->createBatchDeleteForm($this->entityClass, $entities)->createView();
        }

        $newFormWidget = $this->configuration['index_view_new_form'] ? $this->newAction($request, true)->getContent() : null;

        $view = $this->getEntitiesToIndexViewTransformer()->transform($this->meta, $entities);

        return $this->renderResponse('index', [
            'association_param' => $associationParam,
            'batch_delete_form' => $batchDeleteForm,
            'entities_count'    => $entitiesCount,
            'filter_form'       => !empty($filterForm) ? $filterForm->createView() : null,
            'meta'              => $this->meta,
            'new_form_widget'   => $newFormWidget,
            'pagination'        => $pagination,
            'parent_entity'     => $parentEntity,
            'parent_entity_id'  => $parentEntityId,
            'view'              => $view,
        ], $request->isXmlHttpRequest());
    }
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);
    }
67016
public function putCollectionAction(Request $request)
    {
        $result = [];
        foreach ($request->request->all() as $data) {
            if (!isset($data['uid'])) {
                throw new BadRequestHttpException('uid is missing.');
            }

            try {
                $page = $this->getEntityManager()->getRepository('BackBee\NestedNode\Page')->find($data['uid']);

                $this->granted('EDIT', $page);
                if (isset($data['state'])) {
                    $this->granted('PUBLISH', $page);
                }
                $this->updatePage($page, $data);

                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 200,
                    'message'    => 'OK',
                ];
            } catch (NotModifiedException $e) {
                $result[] = [
                    'uid'        => $data['uid'],
                    'statusCode' => 304,
                    'message'    => $e->getMessage(),
                ];
            } catch (AccessDeniedException $e) {
                $result[] = [
                    'uid'        => $data['uid'],
                    'statusCode' => 401,
                    'message'    => $e->getMessage(),
                ];
            } catch (\Exception $e) {
                if ($e instanceof BadRequestHttpException || $e instanceof InsufficientAuthenticationException) {
                    $result[] = [
                        'uid'        => $data['uid'],
                        'statusCode' => 403,
                        'message'    => $e->getMessage(),
                    ];
                } else {
                    $result[] = [
                        'uid'        => $data['uid'],
                        'statusCode' => 500,
                        'message'    => $e->getMessage(),
                    ];
                }
            }
        }

        $this->getEntityManager()->flush();

        return $this->createJsonResponse($result);
    }
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;
    }
413827
private function getParamsFromFilter(FilterBuilder $filter)
    {
        $result  = [];
        $must    = [];
        $mustNot = [];

        $params = $filter->getParams();

        if ($params['entities']) {
            $result['index'] = $params['entities'];
        }

        if (isset($params['keyword'])) {
            $must[] = new MultiMatchQuery($params['keyword']['value'], $params['keyword']['fields']);
        }

        foreach ($params['params'] ?? [] as $param) {
            list($query, $operator) = $param->createFilter();

            if ($operator == FilterOperators::IN) {
                $must[] = $query;
            } else {
                $mustNot[] = $query;
            }

        }

        if ($mustNot || $must) {

            $query = new QueryBuilder();
            if ($mustNot) {
                $query->setMustNot(new MustNotQuery($mustNot));
            }
            if ($must) {
                $query->setMust(new MustQuery($must));
            }

            $result['query'] = $query->toArray();
        }

        return $result;
    }