public function findUserBasket($basket_id, User $user, $requireOwner)
    {
        $dql = 'SELECT b
            FROM Phraseanet:Basket b
            LEFT JOIN b.elements e
            WHERE b.id = :basket_id';

        $query = $this->_em->createQuery($dql);
        $query->setParameters(['basket_id' => $basket_id]);

        $basket = $query->getOneOrNullResult();

        if (null === $basket) {
            throw new NotFoundHttpException($this->trans('Basket is not found'));
        }

        /* @var Basket $basket */
        if ($basket->getUser()->getId() != $user->getId()) {
            $participant = false;

            if ($basket->getValidation() && !$requireOwner) {
                try {
                    $basket->getValidation()->getParticipant($user);
                    $participant = true;
                } catch (\Exception $e) {

                }
            }
            if (!$participant) {
                throw new AccessDeniedHttpException($this->trans('You have not access to this basket'));
            }
        }

        return $basket;
    }
public function findUserBasket($basket_id, User $user, $requireOwner)
    {
        $dql = 'SELECT b
            FROM Phraseanet:Basket b
            LEFT JOIN b.elements e
            WHERE b.id = :basket_id';

        $query = $this->_em->createQuery($dql);
        $query->setParameters(['basket_id' => $basket_id]);

        $basket = $query->getOneOrNullResult();

        if (null === $basket) {
            throw new NotFoundHttpException($this->trans('Basket is not found'));
        }

        /* @var Basket $basket */
        if ($basket->getUser()->getId() != $user->getId()) {
            $participant = false;

            if ($basket->getValidation() && !$requireOwner) {
                try {
                    $basket->getValidation()->getParticipant($user);
                    $participant = true;
                } catch (\Exception $e) {

                }
            }
            if (!$participant) {
                throw new AccessDeniedHttpException($this->trans('You have not access to this basket'));
            }
        }

        return $basket;
    }
public function findUserBasket ( $ basket_id , User $ user , $ requireOwner ) { $ dql = 'SELECT b
            FROM Phraseanet:Basket b
            LEFT JOIN b.elements e
            WHERE b.id = :basket_id' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameters ( [ 'basket_id' => $ basket_id ] ) ; $ basket = $ query -> getOneOrNullResult ( ) ; if ( null === $ basket ) { throw new NotFoundHttpException ( $ this -> trans ( 'Basket is not found' ) ) ; } /* @var Basket $basket */ if ( $ basket -> getUser ( ) -> getId ( ) != $ user -> getId ( ) ) { $ participant = false ; if ( $ basket -> getValidation ( ) && ! $ requireOwner ) { try { $ basket -> getValidation ( ) -> getParticipant ( $ user ) ; $ participant = true ; } catch ( \ Exception $ e ) { } } if ( ! $ participant ) { throw new AccessDeniedHttpException ( $ this -> trans ( 'You have not access to this basket' ) ) ; } } return $ basket ; }
Find a basket specified by his basket_id and his owner

@throws NotFoundHttpException
@throws AccessDeniedHttpException
@param  int $basket_id
@param  User $user
@return Basket
Find a basket specified by his basket_id and his owner