Service DependencyInjection in Symfony2
Try injecting @doctrine.orm.default_entity_manager
.
On web I've found how to connect to Doctrine DBAL to be able to make queries on my own. But when i changed my configuration to this one:
app/config.yml
services: csvimport: class: Tools\TFIBundle\Model\CSVImport arguments: [ @doctrine.dbal.connection, @doctrine.orm.entity_manager, @kernel ]
class definition
namespace Tools\TFIBundle\Model;use Doctrine\ORM\EntityManager, Doctrine\DBAL\Connection, AppKernel;class CSVImport { protected $c; protected $em; protected $kernel; public function __construct(Connection $c, EntityManager $em, AppKernel $k ) { $this->c = $c; $this->em = $em; $this->kernel = $k; }
i got error:
RuntimeException: The definition "csvimport" has a reference to an abstract definition "doctrine.dbal.connection". Abstract definitions cannot be the target of references.
Any ideas?