1

I'm getting an error with using the Symfony service container. 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

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

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.