public function hasRide(Door $door, Door $dest) { if (!isset($this->dests)) { $this->dests = array(); } if (!isset($this->dests[$door->getId()])) { $this->dests[$door->getId()] = array(); $qb = $this->createQueryBuilder('a')->select('b.id')->leftJoin('a.destination', 'b')->where('a.departure = ?1')->setParameter(1, $door); $dests = $qb->getQuery()->getArrayResult(); foreach ($dests as $destid) { $this->dests[$door->getId()][] = $destid['id']; } } return in_array($dest->getId(), $this->dests[$door->getId()]); }
/** * Deletes a Door entity. * * @Secure(roles="ROLE_USER") */ public function deleteAction(Door $entity) { $form = $this->createDeleteForm($entity->getId()); $request = $this->getRequest(); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($entity); $em->flush(); } return $this->redirect($this->generateUrl('door')); }
/** * * @param Door $door * @return Ambigous <multitype:, \Doctrine\ORM\mixed, \Doctrine\ORM\Internal\Hydration\mixed, \Doctrine\DBAL\Driver\Statement, \Doctrine\Common\Cache\mixed> */ public function getByDoor(Door $door) { $qb = $this->createQueryBuilder('a')->select('a')->leftJoin('a.door', 'b')->where('b.id = ?1')->orderBy('a.creation', 'desc')->setParameter(1, $door->getId()); return $qb->getQuery()->getResult(); }