/**
  * @QueryParam(name="foo", default="invalid")
  * @RequestParam(name="bar", default="foo")
  */
 public function testAction(Request $request, ParamFetcherInterface $fetcher)
 {
     $paramsBefore = $fetcher->all();
     $newRequest = new Request();
     $newRequest->query = $request->query;
     $newRequest->request = $request->request;
     $newRequest->attributes->set('_controller', sprintf('%s::paramsAction', __CLASS__));
     $response = $this->container->get('http_kernel')->handle($newRequest, HttpKernelInterface::SUB_REQUEST, false);
     $paramsAfter = $fetcher->all(false);
     return new JsonResponse(array('before' => $paramsBefore, 'during' => json_decode($response->getContent(), true), 'after' => $paramsAfter));
 }
 /**
  * Returns collection of movie comments
  *
  * @ApiDoc(
  *     views={"default", "movie-comment"},
  *     section="MovieComment API",
  *     statusCodes={
  *         200="Returned when successful",
  *         206="Returned when successful",
  *         400="Returned when an error has occurred"
  *     },
  *     responseMap={
  *         200 = {"class": null, "options": {"data_schema": "movie_comment.schema.yml"}}
  *     }
  * )
  *
  * @Route("movie-comments", name="api_movie_comment_get_movie_comments", requirements={
  *     "_scope":  "[\w,]+",
  *     "_oprs":   "\d+",
  *     "_sort":   "ASC|DESC",
  *     "_offset": "\d+",
  *     "_limit":  "\d+"
  * }, defaults={"_format": "json"}, methods={"GET"})
  *
  * @RestExtra\Scope(name="list", path="movie_comment/list.yml")
  *
  * @Rest\QueryParam(name="body", nullable=true, description="Body")
  * @Rest\QueryParam(name="publish", nullable=true, description="Publish")
  * @Rest\QueryParam(name="createdAt", nullable=true, description="Created at")
  *
  * @param ParamFetcherInterface $paramFetcher
  * @param ScopeFetcherInterface $scopeFetcher
  * @param Request $request
  * @return MovieComment[]
  */
 public function getMovieCommentsAction(ParamFetcherInterface $paramFetcher, ScopeFetcherInterface $scopeFetcher, Request $request)
 {
     // Define datagrid builder
     $datagridBuilder = $this->get('glavweb_datagrid.doctrine_datagrid_builder');
     $datagridBuilder->setEntityClassName(MovieComment::class)->setFirstResult($request->get('_offset'))->setMaxResults(min($request->get('_limit', 100), 1000))->setOrderings($request->get('_sort'))->setOperators($request->get('_oprs', []))->setDataSchema('movie_comment.schema.yml', $scopeFetcher->getAvailable($request->get('_scope'), 'movie_comment/list.yml'));
     // Define filters
     $datagridBuilder->addFilter('body')->addFilter('publish')->addFilter('createdAt');
     $datagrid = $datagridBuilder->build($paramFetcher->all());
     return $this->createListViewByDatagrid($datagrid);
 }
 /**
  * Récupère les objets
  *
  * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing objects.")
  * @Annotations\QueryParam(name="limit", requirements="\d+", default="10", description="How many objects to return.")
  * @Annotations\QueryParam(name="sort_field", requirements="\w+", description="Field to use for sorting.", nullable=true)
  * @Annotations\QueryParam(name="sort_order", requirements="^asc|desc$", description="Order of the sort.", nullable=true)
  *
  * @param Request               $request      the request object
  * @param ParamFetcherInterface $paramFetcher param fetcher service
  * 
  * @ApiDoc()
  */
 protected function getObjectsAction(Request $request, ParamFetcherInterface $paramFetcher, $serialize_groups = array())
 {
     $params = $paramFetcher->all();
     list($limit, $offset, $filters, $sort) = $this->getParamsAndFilters($params);
     $count = $this->getServiceHandler()->count($filters);
     $result = $this->getServiceHandler()->all($limit, $offset, $filters, $sort);
     $view = $this->view(array('count' => $count, 'results' => $result));
     $default_serialize_groups = array('Default');
     $serialize_groups = array_merge($default_serialize_groups, $serialize_groups);
     $view->setSerializationContext(SerializationContext::create()->enableMaxDepthChecks()->setGroups($serialize_groups));
     return $this->handleView($view);
 }
Пример #4
0
 /**
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return array
  */
 public function validatesParameters(ParamFetcherInterface $paramFetcher)
 {
     $params = $paramFetcher->all();
     $page = $this->validateParameter($params, 'page');
     $limit = $this->validateParameter($params, 'limit');
     $itemsPerPage = $this->container->getParameter('api_wtw_repositories_items_per_page');
     if ($page > 1) {
         $offset = $page * $itemsPerPage;
     } else {
         $offset = 0;
     }
     return array_merge($params, array('limit' => $limit, 'offset' => $offset));
 }
Пример #5
0
 /**
  * Retrieves the list of galleries (paginated)
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\MediaBundle\Model\Gallery", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for gallery list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of galleries by page")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled galleries filter")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Order by array (key is field, value is direction)")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return Gallery[]
  */
 public function getGalleriesAction(ParamFetcherInterface $paramFetcher)
 {
     $page = $paramFetcher->get('page');
     $count = $paramFetcher->get('count');
     $orderBy = $paramFetcher->get('orderBy');
     $criteria = $paramFetcher->all();
     unset($criteria['page'], $criteria['count'], $criteria['orderBy']);
     foreach ($criteria as $key => $crit) {
         if (null === $crit) {
             unset($criteria[$key]);
         }
     }
     return $this->getGalleryManager()->findBy($criteria, $orderBy, $count, $page);
 }
Пример #6
0
 /**
  * Returns collection of entities
  *
  * @ApiDoc(
  *   section="Entity API"
  *   statusCodes={
  *     200="Returned when successful",
  *     500="Returned when an error has occurred"
  *   }
  * )
  *
  * @Security("is_granted('ROLE_ENTITY_LIST')")
  * @Route("entities.{_format}", name="api_entity_list", methods={"GET"}, defaults={"_format"="json"}, requirements={"_format"="json|xml"})
  *
  * @Rest\Route(requirements={"_format"="json|xml"})
  *
  * @Rest\QueryParam(name="name",    nullable=true, description="Name of entity")
  * @Rest\QueryParam(name="q",       nullable=true, description="Query of customer name, customer phone, street")
  * @Rest\QueryParam(name="_sort",   array=true, requirements="ASC|DESC", nullable=true, description="Sort (key is field, order is direction")
  * @Rest\QueryParam(name="_limit",  requirements="\d+", nullable=true, strict=true, description="Limit")
  * @Rest\QueryParam(name="_offset", requirements="\d+", nullable=true, strict=true, description="Offset")
  *
  * @Rest\View(serializerEnableMaxDepthChecks=true, serializerGroups={"entity_list"})
  *
  * @param ParamFetcherInterface $paramFetcher
  * @return Entity[]
  */
 public function getEntitiesAction(ParamFetcherInterface $paramFetcher)
 {
     $repository = $this->getRepository('OrderBundle:Order');
     $q = $paramFetcher->get('q');
     $fields = $paramFetcher->all();
     unset($fields['q']);
     return $this->matching($repository, $fields, function ($criteria) use($q) {
         /** @var Criteria $criteria */
         $expr = $criteria->expr();
         if ($q) {
             $criteria->andWhere($expr->orX($expr->contains('name', $q), $expr->contains('address', $q)));
         }
     });
 }
Пример #7
0
 /**
  * Returns a paginated list of invoices.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\Component\Invoice\InvoiceInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for invoices list pagination (1-indexed)")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of invoices by page")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query invoices invoice by clause (key is field, value is direction")
  * @QueryParam(name="status", requirements="\d+", nullable=true, strict=true, description="Filter on invoice statuses")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return InvoiceInterface[]
  */
 public function getInvoicesAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedFilters = array('status' => "");
     $page = $paramFetcher->get('page') - 1;
     $count = $paramFetcher->get('count');
     $orderBy = $paramFetcher->get('orderBy');
     $filters = array_intersect_key($paramFetcher->all(), $supportedFilters);
     foreach ($filters as $key => $value) {
         if (null === $value) {
             unset($filters[$key]);
         }
     }
     return $this->invoiceManager->findBy($filters, $orderBy, $count, $page);
 }
Пример #8
0
 /**
  * Retrieves the list of sites (paginated)
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for site list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Maximum number of sites per page")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled sites filter")
  * @QueryParam(name="is_default", requirements="0|1", nullable=true, strict=true, description="Default sites filter")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getSitesAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedFilters = array('enabled' => '', 'is_default' => '');
     $page = $paramFetcher->get('page');
     $count = $paramFetcher->get('count');
     $filters = array_intersect_key($paramFetcher->all(), $supportedFilters);
     foreach ($filters as $key => $value) {
         if (null === $value) {
             unset($filters[$key]);
         }
     }
     $pager = $this->siteManager->getPager($filters, $page, $count);
     return $pager;
 }
Пример #9
0
 /**
  * Core controller handler.
  *
  * @param FilterControllerEvent $event
  *
  * @throws \InvalidArgumentException
  */
 public function paramFetcherOnKernelController(FilterControllerEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
         return;
     }
     $controller = $event->getController();
     if (is_callable($controller) && method_exists($controller, '__invoke')) {
         $controller = [$controller, '__invoke'];
     }
     $this->paramFetcher->setController($controller);
     $attributeName = $this->getAttributeName($controller);
     $request->attributes->set($attributeName, $this->paramFetcher);
     if ($this->setParamsAsAttributes) {
         $params = $this->paramFetcher->all();
         foreach ($params as $name => $param) {
             if ($request->attributes->has($name) && null !== $request->attributes->get($name)) {
                 $msg = sprintf("ParamFetcher parameter conflicts with a path parameter '{$name}' for route '%s'", $request->attributes->get('_route'));
                 throw new \InvalidArgumentException($msg);
             }
             $request->attributes->set($name, $param);
         }
     }
 }
Пример #10
0
 /**
  * Returns a paginated list of baskets.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\Component\Basket\BasketInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for baskets list pagination (1-indexed)")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of baskets by page")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query baskets basket by clause (key is field, value is direction")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return BasketInterface[]
  */
 public function getBasketsAction(ParamFetcherInterface $paramFetcher)
 {
     // No filters implemented as of right now
     $supportedFilters = array();
     $page = $paramFetcher->get('page') - 1;
     $count = $paramFetcher->get('count');
     $orderBy = $paramFetcher->get('orderBy');
     $filters = array_intersect_key($paramFetcher->all(), $supportedFilters);
     foreach ($filters as $key => $value) {
         if (null === $value) {
             unset($filters[$key]);
         }
     }
     return $this->basketManager->findBy($filters, $orderBy, $count, $page);
 }
Пример #11
0
 /**
  * Returns a paginated list of groups.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for groups list pagination (1-indexed)")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of groups by page")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query groups order by clause (key is field, value is direction")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/disabled groups only?")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getGroupsAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedFilters = array('enabled' => '');
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('count');
     $sort = $paramFetcher->get('orderBy');
     $criteria = array_intersect_key($paramFetcher->all(), $supportedFilters);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (!$sort) {
         $sort = array();
     } elseif (!is_array($sort)) {
         $sort = array($sort, 'asc');
     }
     return $this->groupManager->getPager($criteria, $page, $limit, $sort);
 }
 /**
  * Returns a paginated list of addresses.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for addresses list pagination (1-indexed)")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of addresses by page")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query orders addresses by clause (key is field, value is direction")
  * @QueryParam(name="customer", requirements="\d+", nullable=true, strict=true, description="Filter on customer id")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return Sonata\DatagridBundle\Pager\PagerInterface
  */
 public function getAddressesAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedCriteria = array('customer' => "");
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('count');
     $sort = $paramFetcher->get('orderBy');
     $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (!$sort) {
         $sort = array();
     } elseif (!is_array($sort)) {
         $sort = array($sort => 'asc');
     }
     return $this->addressManager->getPager($criteria, $page, $limit, $sort);
 }
 /**
  * Retrieves the list of snapshots (paginated).
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for snapshots list pagination")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Maximum number of snapshots per page")
  * @QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter snapshots for a specific site's id")
  * @QueryParam(name="page_id", requirements="\d+", nullable=true, strict=true, description="Filter snapshots for a specific page's id")
  * @QueryParam(name="root", requirements="0|1", nullable=true, strict=true, description="Filter snapshots having no parent id")
  * @QueryParam(name="parent", requirements="\d+", nullable=true, strict=true, description="Get snapshots being child of given snapshots id")
  * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled snapshots filter")
  * @QueryParam(name="orderBy", requirements="ASC|DESC", array=true, nullable=true, strict=true, description="Order by array (key is field, value is direction)")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return PagerInterface
  */
 public function getSnapshotsAction(ParamFetcherInterface $paramFetcher)
 {
     $supportedCriteria = array('enabled' => '', 'site' => '', 'page_id' => '', 'root' => '', 'parent' => '');
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('count');
     $sort = $paramFetcher->get('orderBy');
     $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (!$sort) {
         $sort = array();
     } elseif (!is_array($sort)) {
         $sort = array($sort => 'asc');
     }
     $pager = $this->snapshotManager->getPager($criteria, $page, $limit, $sort);
     return $pager;
 }
Пример #14
0
 /**
  * Returns a paginated list of baskets.
  *
  * @ApiDoc(
  *  resource=true,
  *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"}
  * )
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page for baskets list pagination (1-indexed)")
  * @QueryParam(name="count", requirements="\d+", default="10", description="Number of baskets by page")
  * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query baskets basket by clause (key is field, value is direction")
  *
  * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true)
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return Sonata\DatagridBundle\Pager\PagerInterface[]
  */
 public function getBasketsAction(ParamFetcherInterface $paramFetcher)
 {
     // No filters implemented as of right now
     $supportedCriteria = array();
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('count');
     $sort = $paramFetcher->get('orderBy');
     $criteria = array_intersect_key($paramFetcher->all(), $supportedCriteria);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (!$sort) {
         $sort = array();
     } elseif (!is_array($sort)) {
         $sort = array($sort => 'asc');
     }
     return $this->basketManager->getPager($criteria, $page, $limit, $sort);
 }
Пример #15
0
 /**
  * Filters criteria from $paramFetcher to be compatible with the Pager criteria.
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return array The filtered criteria
  */
 protected function filterCriteria(ParamFetcherInterface $paramFetcher)
 {
     $criteria = $paramFetcher->all();
     unset($criteria['page'], $criteria['count']);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     return $criteria;
 }
Пример #16
0
 /**
  * Filters criteria from $paramFetcher to be compatible with the Pager criteria
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return array The filtered criteria
  */
 protected function filterCriteria(ParamFetcherInterface $paramFetcher)
 {
     $criteria = $paramFetcher->all();
     unset($criteria['page'], $criteria['count']);
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (array_key_exists('dateValue', $criteria)) {
         $date = new \DateTime($criteria['dateValue']);
         $criteria['date'] = array('query' => sprintf('p.publicationDateStart %s :dateValue', $criteria['dateQuery']), 'params' => array('dateValue' => $date));
         unset($criteria['dateValue'], $criteria['dateQuery']);
     } else {
         unset($criteria['dateQuery']);
     }
     return $criteria;
 }
Пример #17
0
 /**
  * @Rest\Get("/", name="app_api_categories")
  * @Rest\QueryParam(
  *     name="keyword",
  *     requirements="[a-zA-Z0-9]+",
  *     nullable=true,
  *     description="The keyword to search for."
  * )
  * @Rest\QueryParam(
  *     name="order",
  *     requirements="asc|desc",
  *     default="asc",
  *     description="Sort order (asc or desc)."
  * )
  * @Rest\QueryParam(
  *     name="limit",
  *     requirements="\d+",
  *     default="20",
  *     description="Max number of categories per page."
  * )
  * @Rest\QueryParam(
  *     name="offset",
  *     requirements="\d+",
  *     default="0",
  * description="The pagination offset."
  * )
  * @Doc\ApiDoc(
  *     section="Categories",
  *     resource=true,
  *     description="Get the list of all categories.",
  *     statusCodes={
  *          200="Returned when successful",
  *     }
  * )
  */
 public function getCategoriesAction(ParamFetcherInterface $paramFetcher)
 {
     $repository = $this->get('app_core.repository.category');
     $categories = $repository->search($paramFetcher->get('keyword'), $paramFetcher->get('order'), $paramFetcher->get('limit'), $paramFetcher->get('offset'));
     return $this->get('app_api.categories_view_handler')->handleRepresentation(new Categories($categories), $paramFetcher->all());
 }
 /**
  * @RequestParam(name="raw", requirements=@IdenticalTo({"foo"="raw", "bar"="foo"}), default="invalid")
  * @RequestParam(name="map", map=true, requirements=@IdenticalTo({"foo"="map", "foobar"="foo"}), default="invalid2")
  */
 public function paramsAction(ParamFetcherInterface $fetcher)
 {
     return new JsonResponse($fetcher->all(false));
 }
Пример #19
0
 /**
  * List all expenses.
  *
  * @ApiDoc(
  *   resource = true,
  *   statusCodes = {
  *     200 = "Returned when successful"
  *   }
  * )
  *
  * @Annotations\View()
  *
  * @param Request               $request      the request object
  * @param ParamFetcherInterface $paramFetcher param fetcher service
  *
  * @return array
  * 
  * @todo $paramFetcher - also filter down by date, or limit/page
  */
 public function getSummaryAction(Request $request, ParamFetcherInterface $paramFetcher)
 {
     $params = $paramFetcher->all();
     $expenses = $this->getExpenseManager()->calcSummary($params);
     return $expenses;
 }
Пример #20
0
 /**
  * Filters criteria from $paramFetcher to be compatible with the Pager criteria.
  *
  * @param ParamFetcherInterface $paramFetcher
  *
  * @return array The filtered criteria
  */
 protected function filterCriteria(ParamFetcherInterface $paramFetcher)
 {
     $criteria = $paramFetcher->all();
     unset($criteria['page'], $criteria['count']);
     if ($criteria['collection']) {
         $criteria['collection'] = $this->collectionManager->findOneBy(['slug' => $criteria['collection']]);
     }
     if ($criteria['search']) {
         $criteria['search'] = urldecode($criteria['search']);
     }
     foreach ($criteria as $key => $value) {
         if (null === $value) {
             unset($criteria[$key]);
         }
     }
     if (array_key_exists('dateValue', $criteria)) {
         $date = new \DateTime($criteria['dateValue']);
         $criteria['date'] = array('query' => sprintf('p.publicationDateStart %s :dateValue', $criteria['dateQuery']), 'params' => array('dateValue' => $date));
         unset($criteria['dateValue'], $criteria['dateQuery']);
     } else {
         unset($criteria['dateQuery']);
     }
     return $criteria;
 }