所以,我使用 bundle 类来完成我的大部分工作,因为我不需要控制器 (src\CSFs\QuicklinksBundle\CSFsQuicklinksBundle.php)。
从另一个包的 FrontController 中,我得到了快速链接包,将容器对象注入到包类(上图)中,然后在包类中提取模板以返回 HTML,这很好。但是,我在存储库方面遇到了麻烦。
/**
* Get the container object, so we can use all the symfony2 fun stuffs
*/
public function injectContainer($cont)
{
// Template
$this->tpl = $cont->get('templating');
// EM
$this->em = $cont->get('doctrine')->getEntityManager();
}
/**
*
**/
public function doStuff()
{
$products = $this->em->getRepository('QuicklinksBundle:Quicklinks')
->getUsersWithQuicklinks();
}
我得到的错误是:
Unknown Entity namespace alias 'QuicklinksBundle'.
我有生成的实体文件和定义了 getUsersWithQuicklinks() 方法的存储库类。
如何让实体经理了解我的存储库?
谢谢,
麦克风