Controller/JobController.php
public function listAction(Request $request)
    {
        $criteria   = $request->query->get('criteria', array());
        $page       = $request->query->get('page', 1);
        $sortColumn = $request->query->get('sortCol', 'createdAt');
        $sortDir    = $request->query->get('sortDir', 'DESC');
        $limit      = $request->query->get('limit', 10);

        if ($errors = $this->validateQueryParameters($page, $sortColumn, $sortDir, $limit, $criteria)) {

            $response = new BadRequestResponse('Invalid query parameters', 'One or more query parameters are invalid');
            $response->setErrors($errors);

            return $this->serialize($response, 400);
        }

        $page   = (int)$page - 1;
        $offset = ($page > 0) ? ($page) * $limit : 0;

        $criteria = $this->filterCriteria($criteria);

        $manager = $this->getJobManager();

        $entities = $manager->findBy($criteria, [$sortColumn => $sortDir], $limit, $offset);
        $count    = $manager->findByCount($criteria);

        $list = new JobList();
        $list->setItems($entities);
        $list->setTotalCount($count);

        return $this->serialize($list);
    }
public function listAction(Request $request)
    {
        $criteria   = $request->query->get('criteria', array());
        $page       = $request->query->get('page', 1);
        $sortColumn = $request->query->get('sortCol', 'createdAt');
        $sortDir    = $request->query->get('sortDir', 'DESC');
        $limit      = $request->query->get('limit', 10);

        if ($errors = $this->validateQueryParameters($page, $sortColumn, $sortDir, $limit, $criteria)) {

            $response = new BadRequestResponse('Invalid query parameters', 'One or more query parameters are invalid');
            $response->setErrors($errors);

            return $this->serialize($response, 400);
        }

        $page   = (int)$page - 1;
        $offset = ($page > 0) ? ($page) * $limit : 0;

        $criteria = $this->filterCriteria($criteria);

        $manager = $this->getJobManager();

        $entities = $manager->findBy($criteria, [$sortColumn => $sortDir], $limit, $offset);
        $count    = $manager->findByCount($criteria);

        $list = new JobList();
        $list->setItems($entities);
        $list->setTotalCount($count);

        return $this->serialize($list);
    }
public function listAction ( Request $ request ) { $ criteria = $ request -> query -> get ( 'criteria' , array ( ) ) ; $ page = $ request -> query -> get ( 'page' , 1 ) ; $ sortColumn = $ request -> query -> get ( 'sortCol' , 'createdAt' ) ; $ sortDir = $ request -> query -> get ( 'sortDir' , 'DESC' ) ; $ limit = $ request -> query -> get ( 'limit' , 10 ) ; if ( $ errors = $ this -> validateQueryParameters ( $ page , $ sortColumn , $ sortDir , $ limit , $ criteria ) ) { $ response = new BadRequestResponse ( 'Invalid query parameters' , 'One or more query parameters are invalid' ) ; $ response -> setErrors ( $ errors ) ; return $ this -> serialize ( $ response , 400 ) ; } $ page = ( int ) $ page - 1 ; $ offset = ( $ page > 0 ) ? ( $ page ) * $ limit : 0 ; $ criteria = $ this -> filterCriteria ( $ criteria ) ; $ manager = $ this -> getJobManager ( ) ; $ entities = $ manager -> findBy ( $ criteria , [ $ sortColumn => $ sortDir ] , $ limit , $ offset ) ; $ count = $ manager -> findByCount ( $ criteria ) ; $ list = new JobList ( ) ; $ list -> setItems ( $ entities ) ; $ list -> setTotalCount ( $ count ) ; return $ this -> serialize ( $ list ) ; }
@Operation(
tags={"AbcJobBundle"},
summary="Returns a collection of jobs",
@SWG\Response(
response="200",
description="Returned when successful",
@SWG\Schema(
type="array",
@Model(type=Abc\Bundle\JobBundle\Model\JobList::class)
)
),
@SWG\Response(
response="400",
description="Returned when request is invalid",
@Model(type=Abc\Bundle\JobBundle\Api\BadRequestResponse::class)
),
@SWG\Parameter(
name="page",
in="query",
type="integer",
default="1",
format="\d+",
required=false,
description="The page number of the result set"
),
@SWG\Parameter(
name="limit",
in="query",
type="integer",
default="10",
format="\d+",
required=false,
description="The page size"
),
@SWG\Parameter(
name="sortCol",
in="query",
type="string",
default="createdAt",
format="(ticket|type|status|createdAt|terminatedAt)",
required=false,
description="The sort column"
),
@SWG\Parameter(
name="sortDir",
in="query",
type="string",
default="DESC",
format="(ASC|DESC)",
required=false,
description="The sort direction"
),
@SWG\Parameter(
name="criteria",
in="query",
type="array",
@SWG\Items(
type="string"
),
required=false,
description="The search criteria defined as associative array, valid keys are ticket|type|status"
)
)

@param Request $request
@return Response
@Operation ( tags = { AbcJobBundle } summary = Returns a collection of jobs @SWG \ Response ( response = 200 description = Returned when successful @SWG \ Schema ( type = array @Model ( type = Abc \ Bundle \ JobBundle \ Model \ JobList :: class ) ) ) @SWG \ Response ( response = 400 description = Returned when request is invalid @Model ( type = Abc \ Bundle \ JobBundle \ Api \ BadRequestResponse :: class ) ) @SWG \ Parameter ( name = page in = query type = integer default = 1 format = \ d + required = false description = The page number of the result set ) @SWG \ Parameter ( name = limit in = query type = integer default = 10 format = \ d + required = false description = The page size ) @SWG \ Parameter ( name = sortCol in = query type = string default = createdAt format = ( ticket|type|status|createdAt|terminatedAt ) required = false description = The sort column ) @SWG \ Parameter ( name = sortDir in = query type = string default = DESC format = ( ASC|DESC ) required = false description = The sort direction ) @SWG \ Parameter ( name = criteria in = query type = array @SWG \ Items ( type = string ) required = false description = The search criteria defined as associative array valid keys are ticket|type|status ) )