src/Graviton/RestBundle/Listener/LinkHeaderResponseListener.php
private function generateLink($routeName, $page, $perPage, $type, Request $request, $rql)
    {
        $limit = '';
        if ($perPage) {
            $page = ($page - 1) * $perPage;
            $limit = sprintf('limit(%s,%s)', $perPage, $page);
        }
        if (strpos($rql, 'limit') !== false) {
            $rql = preg_replace('/limit\(.*\)/U', $limit, $rql);
        } elseif (empty($rql)) {
            $rql .= $limit;
        } else {
            $rql .= '&'.$limit;
        }

        $url = $this->getRqlUrl(
            $request,
            $this->router->generate($routeName, [], UrlGeneratorInterface::ABSOLUTE_URL) .
            '?' . strtr($rql, [',' => '%2C'])
        );

        $this->linkHeader->add(new LinkHeaderItem($url, array('rel' => $type)));
    }
private function generateLink($routeName, $page, $perPage, $type, Request $request, $rql)
    {
        $limit = '';
        if ($perPage) {
            $page = ($page - 1) * $perPage;
            $limit = sprintf('limit(%s,%s)', $perPage, $page);
        }
        if (strpos($rql, 'limit') !== false) {
            $rql = preg_replace('/limit\(.*\)/U', $limit, $rql);
        } elseif (empty($rql)) {
            $rql .= $limit;
        } else {
            $rql .= '&'.$limit;
        }

        $url = $this->getRqlUrl(
            $request,
            $this->router->generate($routeName, [], UrlGeneratorInterface::ABSOLUTE_URL) .
            '?' . strtr($rql, [',' => '%2C'])
        );

        $this->linkHeader->add(new LinkHeaderItem($url, array('rel' => $type)));
    }
private function generateLink ( $ routeName , $ page , $ perPage , $ type , Request $ request , $ rql ) { $ limit = '' ; if ( $ perPage ) { $ page = ( $ page - 1 ) * $ perPage ; $ limit = sprintf ( 'limit(%s,%s)' , $ perPage , $ page ) ; } if ( strpos ( $ rql , 'limit' ) !== false ) { $ rql = preg_replace ( '/limit\(.*\)/U' , $ limit , $ rql ) ; } elseif ( empty ( $ rql ) ) { $ rql .= $ limit ; } else { $ rql .= '&' . $ limit ; } $ url = $ this -> getRqlUrl ( $ request , $ this -> router -> generate ( $ routeName , [ ] , UrlGeneratorInterface :: ABSOLUTE_URL ) . '?' . strtr ( $ rql , [ ',' => '%2C' ] ) ) ; $ this -> linkHeader -> add ( new LinkHeaderItem ( $ url , array ( 'rel' => $ type ) ) ) ; }
generate link header passed on params and type

@param string  $routeName use with router to generate urls
@param integer $page      page to link to
@param integer $perPage   number of items per page
@param string  $type      rel type of link to generate
@param Request $request   request to get rawRql from
@param string  $rql       rql query string

@return string
generate link header passed on params and type