2014-03-26 3 views

답변

5

당신은 다음과 같이 컨테이너 개체를 얻을 것이다 :

쇼크 Chitroda

+0

감사를

// include files to get container use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; class ClassNameRepository extends EntityRepository implements ContainerAwareInterface { /** * @var ContainerInterface * * @author Ashok Chitroda <[email protected]> */ private $container; public function setContainer(ContainerInterface $container = null) { $this->container = $container; } } 

감사합니다, 그것은 작동합니다. –

+1

작동하지만 그렇게하지 마십시오. 일반적으로 나쁜 습관입니다. 컨테이너를 주입하면 서비스 전체를 주입 할 수 있으며 이는 기본적으로 저장소를 사실상 모든 것에 종속시킵니다. –

+0

@Jakub Zalas, 다른 방법이 있습니까? –

관련 문제