2016-01-13 18 views
0

我试图用PaginatedRepresentation实施HATEOAS,就像描述文档:不能使用的路径没有URL生成

看到波纹管我的控制器:

$hateoas = HateoasBuilder::create()->build(); 
     $paginatedCollection = new PaginatedRepresentation(
      $collection, 
      $this->generateUrl('getUsers'), // route 
      array(), // route parameters 
      1,  // page number 
      2,  // limit 
      11  // total pages 
     ); 


     return new Response($hateoas->serialize($paginatedCollection, 'json'), 
      200, 
      array('Content-Type' => 'application/json')); 

,但我得到这个错误:不能使用的路径没有URL生成

+0

问题是? –

+0

错误:您无法使用没有url生成器的路由。 –

+0

请明确您正在使用的软件包和其余相关代码! –

回答

0

代替:

$hateoas->serialize($paginatedCollection, 'json') 

by

$this->get('serializer')->serialize($paginatedCollection, 'json')