/** * Throws an exception if it already exists a basket with a specific customer id. * * @param $customerId * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ protected function checkExistingCustomerBasket($customerId) { $basket = $this->basketManager->findOneBy(array('customer' => $customerId)); if ($basket instanceof BasketInterface) { throw new HttpException('400', sprintf('Customer (%d) already has a basket', $customerId)); } }
/** * Retrieves basket with id $id or throws an exception if it doesn't exist * * @param $id * * @return BasketInterface * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function getBasket($id) { $basket = $this->basketManager->findOneBy(array('id' => $id)); if (null === $basket) { throw new NotFoundHttpException(sprintf('Basket (%d) not found', $id)); } return $basket; }