在带有奇怪控制器的 symfony 2.3 上使用 Knp paginator

Using Knp paginator on symfony 2.3 with weird controller

我在 symfony 2.3 项目上使用 Knp paginator,这个项目对我来说是新的,所以控制器使用起来有点奇怪。

我正在尝试安装它,但仍有一些问题无法正常运行。

我正在关注这个 tutorial actually

这是我控制器中的代码

private function resultsAction(Request $request, User $user, $type, $archive)
{
     $em = $this->getDoctrine()->getManager();

     $results = $em->getRepository("randomRepo")->findByTypeAndPro($type, $user, $archive);

     /**
      * @var $paginator \Knp\Component\Pager\Paginator
      */
     $paginator = $this->get('knp_paginator');
     $results = $paginator->paginate(
         $results,
         $request->query->getInt('page',1),
         $request->query->getInt('limit',5)
     );


     return array("results" => $results, "archive" => $archive);
}

public function offerAction(User $user, $archive = false)
{
     return $this->resultsAction($user, Operation::OFFER, $archive);
}

我的命名空间和 class 使用:

namespace ST\BackofficeBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use ST\UserBundle\Entity\Operation;
use ST\UserBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

因此,当我尝试加载我的页面时出现此错误:

您忘记将 Request 参数添加到 ResultsAction 调用中。

声明包含 4 个参数:

resultsAction(Request $request, User $user, $type, $archive)

调用包含 3 个:

public function offerAction(User $user, $archive = false)
{
    return $this->resultsAction($user, Operation::OFFER, $archive);
}

调用操作时必须传递请求class:

public function offerAction(Request $request, User $user, $archive = false)
{
    return $this->resultsAction($request, $user, Operation::OFFER, $archive);
}