/** * @test */ public function testGetPagingPropertiesWithModifiedValues() { $command = new FilterCommentsCommand(); $command->limit = 50; $command->page = 2; $command->sort = 'subject'; $command->order = 'DESC'; $processor = new CommentFilterCriteriaProcessor(); $processor->setCommand($command); $pagingProperties = $processor->getPagingProperties(); $this->assertInstanceOf('\\Diamante\\DeskBundle\\Model\\Shared\\Filter\\PagingProperties', $pagingProperties); $this->assertEquals(50, $pagingProperties->getLimit()); $this->assertEquals(2, $pagingProperties->getPage()); $this->assertEquals('subject', $pagingProperties->getSort()); $this->assertEquals('DESC', $pagingProperties->getOrder()); }
/** * Retrieves list of all Comments. * Filters comments with parameters provided via GET request. * Time filtering parameters as well as paging/sorting configuration parameters can be found in \Diamante\DeskBundle\Api\Command\CommonFilterCommand class. * Time filtering values should be converted to UTC * * @ApiDoc( * description="Returns all tickets.", * uri="/comments.{_format}", * method="GET", * resource=true, * statusCodes={ * 200="Returned when successful", * 403="Returned when the user is not authorized to list tickets" * } * ) * * @param Command\Filter\FilterCommentsCommand $command * @return Comment[] */ public function listAllComments(Command\Filter\FilterCommentsCommand $command) { $criteriaProcessor = new CommentFilterCriteriaProcessor(); $criteriaProcessor->setCommand($command); $criteria = $criteriaProcessor->getCriteria(); $pagingProperties = $criteriaProcessor->getPagingProperties(); $repository = $this->getCommentsRepository(); $comments = $repository->filter($criteria, $pagingProperties); try { $pagingInfo = $this->apiPagingService->getPagingInfo($repository, $pagingProperties, $criteria); $this->populatePagingHeaders($this->apiPagingService, $pagingInfo); } catch (\Exception $e) { } return $comments; }