我有这个Paginator
类构造函数:
class Paginator
{
public function __construct($total_count, $per_page, $current_page)
{
}
}
该Paginator
服务的注册Ibw/JobeetBundle/Resources/config/services.yml
方式如下:
parameters:
ibw_jobeet_paginator.class: Ibw\JobeetBundle\Utils\Paginator
services:
ibw_jobeet_paginator:
class: %ibw_jobeet_paginator.class%
当我使用Paginator
这样的:
$em = $this->getDoctrine()->getManager();
$total_jobs = $em->getRepository('IbwJobeetBundle:Job')->getJobsCount($id);
$per_page = $this->container->getParameter('max_jobs_on_category');
$current_page = $page;
$paginator = $this->get('ibw_jobeet_paginator')->call($total_jobs, $per_page, $current_page);
我得到这个例外:
警告:缺少 Ibw\JobeetBundle\Utils\Paginator::__construct() 的参数 1,在第 1306 行的 /var/www/jobeet/app/cache/dev/appDevDebugProjectContainer.php 中调用并在 /var/www/jobeet/ 中定义src/Ibw/JobeetBundle/Utils/Paginator.php 第 13 行
我想将参数传递给Paginator
服务构造函数时有问题。你能告诉我,如何将参数传递给服务构造函数吗?