我很抱歉问这样一个问题,我知道以前有过类似的问题,但我的情况相当......愚蠢。我拥有的是一个项目管理系统,我希望显示所有可以正常工作并由Symfony自动生成的项目。在同一个控制器是ProjectController我做了另一个动作。我想列出所有已完成的已存档项目。首先,我只需复制粘贴的代码和注释,并更改路线和函数的名称。这是我的indexAction
功能Symfony错误 - 找不到对象
/**
* Lists all project entities.
*
* @Route("/", name="project_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$projects = $em->getRepository('AppBundle:Project')->findAll();
return $this->render('project/index.html.twig', array(
'projects' => $projects,
));
}
它是尽可能简单,因为它可以得到。现在,这里是我的archiveAction
功能是相同
/**
* Lists all project entities.
*
* @Route("/archive", name="project_archive")
* @Method("GET")
*/
public function archiveAction()
{
$em = $this->getDoctrine()->getManager();
$projects = $em->getRepository('AppBundle:Project')->findAll();
return $this->render('project/index.html.twig', array(
'projects' => $projects,
));
}
到目前为止,我甚至不过滤的项目,但在做同样的事情,我在脑海中indexAction
功能和熊做两个功能都在同一个控制器。这是我在尝试显示所有归档项目时收到的错误 -
未找到AppBundle \ Entity \ Project对象。
index操作工作得很好,并显示所有项目,但如果我改变了路线,改变函数的名称,并把一切都相同,它们是在同一个控制器 - 在一种情况下,它可以找到的appbundle \ Entity \ Zadanie,但在另一种情况下 - 它不能。
我不能在代码中查看Zadanie,在哪里调用?它的代码在哪里? –
这是“项目”我改变它在保加利亚和忘了重做它。它是“AppBundle:Entity:Project” –
您是否在清除symfony的缓存后尝试过? –