/** * Returns a paginated list of customers. * * @ApiDoc( * resource=true, * output={"class"="Sonata\Component\Customer\CustomerInterface", "groups"="sonata_api_read"} * ) * * @QueryParam(name="page", requirements="\d+", default="1", description="Page for customers list pagination (1-indexed)") * @QueryParam(name="count", requirements="\d+", default="10", description="Number of customers by page") * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Query customers order by clause (key is field, value is direction") * * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true) * * @param ParamFetcherInterface $paramFetcher * * @return CustomerInterface[] */ public function getCustomersAction(ParamFetcherInterface $paramFetcher) { // No supported filters as of 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->customerManager->findBy($filters, $orderBy, $count, $page); }