当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Can't use entityManager in service

问题描述:

I'm having a hard time tryig to acces entityManager from a service.

Here's the error thrown :

You cannot dump a container with parameters that contain references to other services (reference to service "doctrine.orm.entity_manager" found in "/em")

Service Class :

class ImpressionClassementService{

protected $em;

public function __construct(EntityManager $entityManager, $parameters)

{

$this->em = $entityManager;

$this->parameters = $parameters;

}

public function imprimerAction()

{ ...}

}

services.yml :

services:

paces_colle.imprimerclassement:

class: PACES\ColleBundle\Services\ImpressionClassementService

arguments: ['%em%', '%parameters%']

parameters.yml :

parameters:

parameters: ''

em: '@doctrine.orm.entity_manager'

Parameters is an argument set when I call the service so it's blank here.

分享给朋友:
您可能感兴趣的文章:
随机阅读: