NotFoundHttpException:无法找到实体错误

时间:2013-08-02 14:41:25

标签: symfony doctrine-orm symfony-2.3

我的控制器中有这个代码:

namespace BankBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use BankBundle\Entity\Account;
use BankBundle\Entity\AccountType;
use BankBundle\Form\AccountType;

也有这种方法:

/**
 * Show created bank account
 *
 * @Route("/account/show/{account_id}", name="wba_show")
 * @Method("GET")
 */
public function showBAAction($account_id) {
    $em = $this->getDoctrine()->getManager();
    $entity = $em->getRepository('BankBundle:Account')->find($account_id);

    if (!$entity) {
        throw $this->createNotFoundException('Unable to find Account entity.');
    }

    $deleteForm = $this->createDeleteForm($account_id);
    return array('entity' => $entity, 'delete_form' => $deleteForm->createView());
}

当我调用网址/account/show/1时,我直接得到了例外,为什么?我想念一些东西吗?

0 个答案:

没有答案