小编Oph*_*hus的帖子

传递给控制器​​的参数必须是ContainerInterface的实例,给定appDevDebugProjectContainer的实例

为什么会出现此错误?

可捕获的致命错误:传递给Application \ Sonata \ ProductBundle \ Controller \ ProductAdminController :: __ construct()的参数1必须是ContainerInterface的实例,给定appDevDebugProjectContainer的实例

这是我的services.yml:

services:
    product_admin_controller:
      class: Application\Sonata\ProductBundle\Controller\ProductAdminController
      arguments: ["@service_container"]
      tags:
            - { name: doctrine.event_listener, event: postLoad, connection: default  }
Run Code Online (Sandbox Code Playgroud)

而我的控制器:

class ProductAdminController extends Controller
{
    protected $container;

    public function __construct(\ContainerInterface $container)
    {
        $this->container = $container;
    }
}
Run Code Online (Sandbox Code Playgroud)

dependency-injection symfony sonata

5
推荐指数
1
解决办法
5825
查看次数

标签 统计

dependency-injection ×1

sonata ×1

symfony ×1