Inheritance: extends RestException
Exemple #1
0
 /**
  * Change a filter by the given id.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param int $id the attribute id
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function putAction(Request $request, $id)
 {
     try {
         $filter = $this->getManager()->save($request->request->all(), $this->getLocale($request), $this->getUser()->getId(), $id);
         $view = $this->view($filter, 200);
     } catch (FilterDependencyNotFoundException $exc) {
         $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
         $view = $this->view($exception->toArray(), 400);
     } catch (FilterNotFoundException $exc) {
         $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
         $view = $this->view($exception->toArray(), 404);
     } catch (MissingFilterException $exc) {
         $exception = new MissingArgumentException(self::$entityName, $exc->getFilter());
         $view = $this->view($exception->toArray(), 400);
     } catch (ConditionGroupMismatchException $exc) {
         $exception = new InvalidArgumentException(self::$groupConditionEntityName, $exc->getId());
         $view = $this->view($exception->toArray(), 400);
     } catch (UnknownContextException $exc) {
         $exception = new RestException($exc->getMessage());
         $view = $this->view($exception->toArray(), 400);
     }
     return $this->handleView($view);
 }
 /**
  * Change a shipping.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param integer $id shipping ID
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function putAction(Request $request, $id)
 {
     try {
         $shipping = $this->getManager()->save($request->request->all(), $this->getLocale($request), $this->getUser()->getId(), $id);
         $view = $this->view($shipping, 200);
     } catch (ShippingNotFoundException $exc) {
         $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
         $view = $this->view($exception->toArray(), 404);
     } catch (ShippingDependencyNotFoundException $exc) {
         $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
         $view = $this->view($exception->toArray(), 400);
     } catch (MissingShippingAttributeException $exc) {
         $exception = new MissingArgumentException(self::$shippingEntityName, $exc->getAttribute());
         $view = $this->view($exception->toArray(), 400);
     } catch (ShippingException $exc) {
         $exception = new RestException($exc->getMessage());
         $view = $this->view($exception->toArray(), 400);
     }
     return $this->handleView($view);
 }