Vote count:
0
I have a couple of days something lost with the declaration of services, especially when passing parameters to custom classes.
I have several extensions and listeners declared as services, to which I pass parameters to the constructor and operating properly but do the same for a custom class and does not work.
The error is that the class does not receive parameters in the constructor.
Error:
Catchable Fatal Error: Argument 1 passed to Consolidador\PanelBundle\Controller\Integration::__construct() must be an instance of Doctrine\Bundle\DoctrineBundle\Registry, none given, called in /var/www/vhosts/consolidadordeviajes.com/httpdocs/src/Consolidador/PanelBundle/Controller/HotelsController.php on line 149 and defined
This is the service that stated in app/config/services.yml
:
integration:
class: Consolidador\PanelBundle\Controller\Integration
arguments: ['@doctrine', '@session']
This is the custom class:
<?php
namespace Consolidador\PanelBundle\Controller;
use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine;
use Symfony\Component\HttpFoundation\Session\Session;
class Integration
{
private $em;
private $session;
public function __construct(Doctrine $doctrine, Session $session)
{
$this->em = $doctrine->getEntityManager();
$this->session = $session;
}
...
When I call the custom class is when the error occurs, I think I'm stating the service and collecting the parameters correctly, if not, I hope that other eyes may see the error that I get not find.
A greeting and thanks.
asked 30 secs ago
Class does not receive parameters sent by a service. Symfony2
Aucun commentaire:
Enregistrer un commentaire