我有一个存储库
class TurnoRepository extends EntityRepository
{
public function findTurnoActivo()
{
$q = $this
->createQueryBuilder('t')
->where('t.activo = :activo')
->setParameter('activo', true)
->getQuery();
return $q->getSingleResult();
}
}
此方法抛出 NoResultException 但如果我尝试在我的控制器中捕获
private function obtenerTurno()
{
$em = $this->getDoctrine()->getEntityManager();
$turno = null;
try {
$turnoActivo = $em->getRepository('MyBundle:Turno')->findTurnoActivo();
} catch (NoResultException $e) {
return false;
}
return $turno;
}
我总是在我的页面上收到 500 Internal Server Error