I use simplified controller and have no service container. I'm trying to inject doctrine into a service. Here is the error:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Acme\Controller\WebController::__construct() must be an instance of Doctrine\ORM\EntityManager, none given, called in /home/hcs/Core/app/cache/dev/appDevDebugProjectContainer.php on line 3036 and defined in /home/hcs/Core/src/Acme/Controller/WebController.php line 28
Here is my service def:
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
mappings:
Acme:
type: annotation
dir: %kernel.root_dir%/../src/Acme/Model
prefix: Acme\Model
alias: Model
is_bundle: false
services:
WebController:
class: Acme\Controller\WebController
arguments: [@doctrine.orm.entity_manager ]
parent: elnur.controller.abstract
And my class
use Doctrine\ORM\EntityManager;
/**
* @Service("WebController", parent="elnur.controller.abstract")
*/
class WebController extends AbstractController
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
Here is output from SF2 container (php app/console container:debug | grep -i en tity)
doctrine.orm.default_entity_manager container EntityManager5330e85ad5afb_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager
doctrine.orm.entity_manager n/a alias for doctrine.orm.default_entity_manager
doctrine.orm.validator.unique container Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator
form.type.entity container Symfony\Bridge\Doctrine\Form\Type\EntityType
translator container Symfony\Component\Translation\IdentityTranslator
I've also tried arguments: [ "@doctrine.orm.entity_manager" ] in the service definition and still nothing. I've tried cleaning my cache, but I cannot for the life of me get an EM injected. What am I doing wrong?