0
我有一個自定義控制器,擴展controller
(Symfony\Bundle\FrameworkBundle\Controller\Controller
),它又擴展了ContainerAware
(Symfony\Component\DependencyInjection\ContainerAware
)。
在我使用的所有功能中;Symfony控制器 - 添加屬性
$foo = $this->get('foo');
所以我想能夠像我這樣構建我的班級;
<?php
class FooController extends Controller
{
private $fooManager;
function indexAction()
{
// ...
$this->fooManager->getAllFoo($scope);
// ...
}
}
添加一個構造函數在我的自定義類將無法正常工作的ContainerAware
設置容器setContainer(ContainerInterface $container = null)
功能。
我試過在我的控制器中覆蓋這個函數,但仍然沒有好處。
我該如何實施?