I have this controller:
use Doctrine\Common\Persistence\ManagerRegistry;
class AjaxEntityController
{
protected $registry;
public function __construct(ManagerRegistry $registry)
{
$this->registry = $registry;
}
...
}
And this is my services.yml:
services:
tapir_form.ajax_entity_controller:
class: Tapir\FormBundle\Controller\AjaxEntityController
arguments: [ '@doctrine' ]
But when I try to access this controller (by it's URL), I get this error:
Type error: Argument 1 passed to Tapir\FormBundle\Controller\AjaxEntityController::__construct() must implement interface Doctrine\Common\Persistence\ManagerRegistry, none given, called in /..../var/cache/dev/jms_diextra/controller_injectors/TapirFormBundleControllerAjaxEntityController.php on line 13
I've searched for this problem, and found lots of cases where the controller was not declared as a service or the arguments parameter was missing, but it's not my case.
I cleared the cache, added @Route(service="tapir_form.ajax_entity_controller") to my controller class, just in case. Of course I have my TapirFormExtension
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
If I remove the mandatory parameter from the constructor, the service works (I mean the controller action is called, no exception). This is the first time I use a controller as a service. Other services like form types are working with a similar configuration.
I'm using Symfony 2.7.3, PHP 5.6.13, Linux.
What else can be wrong?
Thanks in advance.
routing.ymlfile, and later you defined service in@Routeannotation.. - malcolm