Trying to pass a Doctrine dbal connection to my construct in a controller.
I am following this link to do it but it is not working:
How do you access Doctrine DBAL in a Symfony2 service class?
Here is my service inside app/config/config.yml
services:
form1:
class: Test\TestBundle\Controller\FormController
arguments: [@doctrine.dbal.form1_connection]
Here is my controller with construct
namespace Test\TestBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\RestBundle\Util\Codes;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Doctrine\DBAL\Connection;
class FormController extends FOSRestController implements ClassResourceInterface
{
private $connection;
public function __construct(Connection $dbalConnection) {
$this->connection = $dbalConnection;
}
}
I get this error "message": "Catchable Fatal Error: Argument 1 passed to Test\TestBundle\Controller\FormController::__construct() must be an instance of Doctrine\DBAL\Connection, none given, called in /srv/test/tmp/dev/cache/classes.php on line 2449 and defined in /vagrant/test.com/src/Test/TestBundle/Controller/FormController.php
Here is app/config/routing.yml
test_form:
pattern: /api/v4/forms.{_format}
defaults: { _controller: TestTestBundle:Form:cget, _format: json }
requirements:
_method: GET
Any help would be great. thx