2012-07-29 81 views

回答

70

如果從ContainerAwareCommand延長你應該能夠得到您的服務

$this->getContainer()->get('doctrine'); 

Here是類似的問題

+0

感謝;)我在'Symfony \ Component \ Console'命名空間中搜索,但我沒有注意到'Symfony \ Bundle \ FrameworkBundle \ Console'和'Symfony \ Bundle \ FrameworkBundle \ Command'。 – pamil 2012-07-29 13:26:47

+0

確切定義了'getContainer'方法的位置?我無法在ContainterAwareCommand上找到它。 – Luke 2013-04-11 03:32:01

+0

@Luke AFAIK這個答案與'2.0'版本有關。你正在使用哪個版本? – 2013-04-11 19:13:10

相關問題