_em->createQuery($dql); $query->setParameters(array('usr_id' => $user->get_id())); return $query->getResult(); } /** * Returns all baskets that are in validation session not expired and * where a specified user is participant (not owner) * * @param \User_Adapter $user * @return \Doctrine\Common\Collections\ArrayCollection */ public function findActiveValidationByUser(\User_Adapter $user) { $dql = 'SELECT b FROM Entities\Basket b JOIN b.validation s JOIN s.participants p WHERE b.usr_id != ?1 AND p.usr_id = ?2 AND s.expires > CURRENT_TIMESTAMP()'; $query = $this->_em->createQuery($dql); $query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id())); return $query->getResult(); } public function findUserBasket($basket_id, \User_Adapter $user) { $basket = $this->find($basket_id); /* @var $basket Entities\Basket */ if (null === $basket) { throw new \Exception_NotFound(_('Basket is not found')); } if ($basket->getowner()->get_id() != $user->get_id()) { throw new \Exception_Forbidden(_('You have not access to this basket')); } return $basket; } }