2017-12-16 14 views
0

나는 서비스로 공공 가시성 "교리 \ ORM \ EntityManager의"추가했습니다 :잘못된 서비스 "교리 ORM EntityManager의"생성자는 공개해야한다

enter image description here

하지만 난이 오류가 발생했습니다 : 내 컨트롤러에 EntityManager를 주입 할

enter image description here

. 뭐가 문제 야?

+0

왜 당신이 컨트롤러에 EntityManager를 주입하는 사용하여 수행 할 수 있습니다? Controller에서 EntityManager를 호출 할 수 있습니다. –

답변

1

"Doctrine \ ORM \ EntityManager"오류 "생성자가 공개이어야합니다.", 기본적으로 symfony는 클래스로 이름을 사용하여 서비스를 만들고 팩토리가 정의되지 않은 경우 해당 생성자를 호출하기 때문에 서비스를 생성하려고 시도합니다.

parameters: 
    doctrine.orm.entitymanager.factory: Doctrine\ORM\EntityManager 

services: 
    Doctrine\ORM\EntityManager: 
     class: Doctrine\ORM\EntityManager 
     factory: ["%doctrine.orm.entitymanager.factory%", "create"] 
     arguments: 
      $connection: "provide the connection also here" 
      $config: "provide the config also here" 
     public: true 

라인 클래스 : 생략하면 교리 \ ORM \ EntityManager의이 경우에 필요하지 않습니다, 클래스는 서비스 이름으로 기본 설정됩니다 당신은 공장 기능과 인수를 제공해야합니다.

서비스로 공장 인수 ($ connection & config)도 정의하고 공장에 제공해야합니다.

난 당신이 뭘 하려는지 모르겠지만, 당신이 찾고있는 어쩌면 무엇을 이미 Doctrine Bundle