src/Controller/Product/GetProductFormAction.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Product;
  3. use App\Model\Form\FormSchema;
  4. use App\Service\Product\ProductFormHandler;
  5. use App\Voters\ProductVoter;
  6. use ReflectionException;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  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. class GetProductFormAction extends AbstractController
  17. {
  18.     /**
  19.      * @var ProductFormHandler
  20.      */
  21.     private $productFormHandler;
  22.     /**
  23.      * @param ProductFormHandler $productFormHandler
  24.      */
  25.     public function __construct(ProductFormHandler $productFormHandler)
  26.     {
  27.         $this->productFormHandler $productFormHandler;
  28.     }
  29.     /**
  30.      * @param Request     $request
  31.      * @param string|null $id
  32.      *
  33.      * @return FormSchema|JsonResponse
  34.      *
  35.      * @throws ClientExceptionInterface
  36.      * @throws DecodingExceptionInterface
  37.      * @throws RedirectionExceptionInterface
  38.      * @throws ReflectionException
  39.      * @throws ServerExceptionInterface
  40.      * @throws TransportExceptionInterface
  41.      * @throws ExceptionInterface
  42.      */
  43.     public function __invoke(Request $requeststring $id null)
  44.     {
  45.         $this->denyAccessUnlessGranted(ProductVoter::PRODUCT_ADD_EDIT);
  46.         return $this->productFormHandler->getProductForm($id, (bool) $request->query->get('isLegacy'false));
  47.     }
  48. }