我想通過下面的實體訪問服務容器,但是如何實現?注入或訪問實體對象內的服務容器
檢查了這一點,但是當我正在讀聽者時,我迷了路;
控制器
public function indexAction()
{
$orders = $this->getDoctrine()->getManager()->getRepository('MyAdminBundle:Orders')->findAll();
.....
}
實體
namespace My\AdminBundle\Entity;
class Orders
{
private $container;
public function __constructor()
{
$this->container = ??????
}
public function getCurrency()
{
return $this->container->getParameter('currency');
}
}
'global $ kernel;'正是我想要的:)謝謝 – BentCoder 2014-09-11 21:03:28