public function search($class, array $finderParams = [], array $serializerOptions = [])
    {
        $queryParams = self::parseQueryParams($finderParams);
        $page = $queryParams['page'];
        $limit = $queryParams['limit'];
        $filters = $queryParams['filters'];
        $allFilters = $queryParams['allFilters'];
        $sortBy = $queryParams['sortBy'];
        // count the total results (without pagination)
        $count = $this->fetch($class, $allFilters, $sortBy, $page, $limit, true);
        // get the list of data for the current search and page
        $data = $this->fetch($class, $allFilters, $sortBy, $page, $limit);

        if (0 < $count && empty($data)) {
            // search should have returned results, but we have requested a non existent page => get the last page
            $page = ceil($count / $limit) - 1;
            // load last page data
            $data = $this->fetch($class, $allFilters, $sortBy, $page, $limit);
        }

        return self::formatPaginatedData(
            array_map(function ($result) use ($serializerOptions) {
                return $this->serializer->serialize($result, $serializerOptions);
            }, $data),
            $count,
            $page,
            $limit,
            $filters,
            $sortBy
        );
    }
public function search($class, array $finderParams = [], array $serializerOptions = [])
    {
        $queryParams = self::parseQueryParams($finderParams);
        $page = $queryParams['page'];
        $limit = $queryParams['limit'];
        $filters = $queryParams['filters'];
        $allFilters = $queryParams['allFilters'];
        $sortBy = $queryParams['sortBy'];
        // count the total results (without pagination)
        $count = $this->fetch($class, $allFilters, $sortBy, $page, $limit, true);
        // get the list of data for the current search and page
        $data = $this->fetch($class, $allFilters, $sortBy, $page, $limit);

        if (0 < $count && empty($data)) {
            // search should have returned results, but we have requested a non existent page => get the last page
            $page = ceil($count / $limit) - 1;
            // load last page data
            $data = $this->fetch($class, $allFilters, $sortBy, $page, $limit);
        }

        return self::formatPaginatedData(
            array_map(function ($result) use ($serializerOptions) {
                return $this->serializer->serialize($result, $serializerOptions);
            }, $data),
            $count,
            $page,
            $limit,
            $filters,
            $sortBy
        );
    }
public function search ( $ class , array $ finderParams = [ ] , array $ serializerOptions = [ ] ) { $ queryParams = self :: parseQueryParams ( $ finderParams ) ; $ page = $ queryParams [ 'page' ] ; $ limit = $ queryParams [ 'limit' ] ; $ filters = $ queryParams [ 'filters' ] ; $ allFilters = $ queryParams [ 'allFilters' ] ; $ sortBy = $ queryParams [ 'sortBy' ] ; // count the total results (without pagination) $ count = $ this -> fetch ( $ class , $ allFilters , $ sortBy , $ page , $ limit , true ) ; // get the list of data for the current search and page $ data = $ this -> fetch ( $ class , $ allFilters , $ sortBy , $ page , $ limit ) ; if ( 0 < $ count && empty ( $ data ) ) { // search should have returned results, but we have requested a non existent page => get the last page $ page = ceil ( $ count / $ limit ) - 1 ; // load last page data $ data = $ this -> fetch ( $ class , $ allFilters , $ sortBy , $ page , $ limit ) ; } return self :: formatPaginatedData ( array_map ( function ( $ result ) use ( $ serializerOptions ) { return $ this -> serializer -> serialize ( $ result , $ serializerOptions ) ; } , $ data ) , $ count , $ page , $ limit , $ filters , $ sortBy ) ; }
Builds and fires the query for a given class. The result will be serialized afterwards.

@param string $class
@param array  $finderParams
@param array  $serializerOptions

@return array
Builds and fires the query for a given class . The result will be serialized afterwards .