src/Controller/ViewOrderInfoController.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\CustomDataPersister\ViewOrderInfoDataPersister;
  4. use App\Service\ViewOrders\ViewOrdersFormatter;
  5. use Doctrine\Common\Annotations\AnnotationException;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Serializer\Exception\ExceptionInterface;
  11. use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
  12. use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
  13. use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
  14. use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
  15. use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
  16. /**
  17.  * Class ViewOrderInfoController.
  18.  */
  19. final class ViewOrderInfoController extends AbstractController
  20. {
  21.     /**
  22.      * ViewOrderInfo Put Action.
  23.      *
  24.      * @Route("/api/view_orders_info", name="view_order_info_edit_route", methods={"PUT"})
  25.      *
  26.      * @param Request                    $request
  27.      * @param ViewOrdersFormatter        $viewOrdersFormatter
  28.      * @param ViewOrderInfoDataPersister $viewOrderInfoDataPersister
  29.      *
  30.      * @return JsonResponse
  31.      *
  32.      * @throws AnnotationException
  33.      * @throws ClientExceptionInterface
  34.      * @throws RedirectionExceptionInterface
  35.      * @throws ServerExceptionInterface
  36.      * @throws TransportExceptionInterface
  37.      * @throws ExceptionInterface
  38.      * @throws DecodingExceptionInterface
  39.      */
  40.     public function editViewOrderInfo(
  41.         Request $request,
  42.         ViewOrdersFormatter $viewOrdersFormatter,
  43.         ViewOrderInfoDataPersister $viewOrderInfoDataPersister
  44.     ) {
  45.         $jsonRequest json_decode($request->getContent(), true);
  46.         return new JsonResponse($viewOrderInfoDataPersister
  47.             ->handleSaveMultiplesViewOrderInfos($viewOrdersFormatter->getObjectsFromFormat($jsonRequest)));
  48.     }
  49. }