简体   繁体   English

Symfony服务容器-可捕获的致命错误-传递给构造的参数

[英]Symfony service container - Catchable Fatal Error - Argument passed to construct

I'm getting an error with using the Symfony service container. 使用Symfony服务容器时出现错误。 This is the error I'm getting: 这是我得到的错误:

Catchable Fatal Error: Argument 3 passed to housesBundle\Model\PropertyDetailsModel::__construct() must be an instance of
housesBundle\Model\AuditModel, instance of sharedBundle\Model\AuditModel given,
called in /var/www/anildave/symfony/app/cache/dev/appDevDebugProjectContainer.php   
on line 1876 and defined
500 Internal Server Error - ContextErrorException

services.yml services.yml

audit_model_service:
    class: sharedBundle\Model\AuditModel
    arguments: [@doctrine.dbal.default_connection]

property_details_model_service:
    class: housesBundle\Model\PropertyDetailsModel
    arguments: [@doctrine.dbal.default_connection,@request_stack,@audit_model_service]
    calls:
        - [ setContainer, [ @service_container ]]

PropertyDetailsModel.php PropertyDetailsModel.php

namespace housesBundle\Model;

use Doctrine\DBAL\Connection;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use sharedBundle\Model;
use sharedBundle\Helper;

class PropertyDetailsModel extends Controller
{
    private $connection;
    private $requestStack;
    private $auditModel;

    public function __construct(Connection $connection, RequestStack          $requestStack, AuditModel $auditModel)
    {
        $this->connection = $connection;
        $this->requestStack = $requestStack;
        $this->auditModel = $auditModel;
    }

I'm not sure what I'm doing wrong. 我不确定自己在做什么错。

Thanks 谢谢

Look at your uses : 查看您的用途:

use Doctrine\DBAL\Connection;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use sharedBundle\Model;
use sharedBundle\Helper;
use sharedBundle\Model\AuditModel;     // <---- Look here, add this

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony2:ContextErrorException:可捕获的致命错误:传递给[…] :: __ construct()的参数1必须实现接口[…]没有给出 - Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to […]::__construct() must implement interface […] none given Symfony 2可捕获的致命错误:传递给Sg \\ DatatablesBundle \\ Datatable \\ :: __ construct()的参数1必须是的实例 - Symfony 2 Catchable Fatal Error: Argument 1 passed to Sg\DatatablesBundle\Datatable\::__construct() must be an instance of Symfony2可捕获的致命错误:参数1传递给实体可捕获的致命错误:参数1传递给实体 - Symfony2 Catchable Fatal Error: Argument 1 passed to entity Catchable Fatal Error: Argument 1 passed to entity 椭圆曲线密码术PHP:可捕获的致命错误参数1传递给__construct() - Elliptic Curve Cryptography PHP: catchable fatal error argument 1 passed to __construct() Sylius:可捕获的致命错误:参数1传递给ShopBundle \\ Controller \\ HomepageController :: __ construct() - Sylius : Catchable Fatal Error: Argument 1 passed to ShopBundle\Controller\HomepageController::__construct() 可捕获的致命错误:传递给“…\\ FormType :: __ construct()的参数1必须实现接口 - Catchable Fatal Error: Argument 1 passed to "…\FormType::__construct() must implement interface 可捕获的致命错误:参数1传递给 - Catchable Fatal Error: Argument 1 passed to 在Symfony2中上载文件:可捕获的致命错误:参数1传递给 - Upload file in Symfony2: Catchable Fatal Error: Argument 1 passed to 可捕获的致命错误:参数1传递给? Symfony2.1 - Catchable Fatal Error: Argument 1 passed to ? Symfony2.1 可捕获的致命错误:参数1传递给CorenlpAdapter :: getOutput() - Catchable fatal error: Argument 1 passed to CorenlpAdapter::getOutput()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM