1 回答

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個贊
命名空間Venom \ CoreBundle;使用Symfony \ Component \ HttpKernel \ Bundle \ Bundle;use \ Symfony \ Component \ DependencyInjection \ ContainerInterface;VenomCoreBundle類擴(kuò)展了Bundle{
private static $ containerInstance = null;
public function setContainer(ContainerInterface $ container = null)
{
父:: setContainer($容器);
self :: $ containerInstance = $ container;
}
public static function getContainer()
{
return self :: $ containerInstance;
}
}
使用適當(dāng)?shù)拿臻g。然后,在需要容器的類中使用bundle的命名空間。您可以通過調(diào)用容器
$ container = VenomCoreBundle :: getContainer()
- 1 回答
- 0 關(guān)注
- 948 瀏覽
添加回答
舉報