src/V4/Controller/Section/GetSectionFormAction.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\V4\Controller\Section;
  3. use ApiPlatform\Core\Exception\ResourceClassNotSupportedException;
  4. use App\Model\Form\FormSchema;
  5. use App\V4\Service\Section\SectionFormHandler;
  6. use App\V4\Voters\SectionVoter;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class GetSectionFormAction extends AbstractController
  10. {
  11.     /**
  12.      * @var SectionFormHandler
  13.      */
  14.     private $sectionFormHandler;
  15.     /**
  16.      * @param SectionFormHandler $sectionFormHandler
  17.      */
  18.     public function __construct(SectionFormHandler $sectionFormHandler)
  19.     {
  20.         $this->sectionFormHandler $sectionFormHandler;
  21.     }
  22.     /**
  23.      * @param Request     $request
  24.      * @param string|null $id
  25.      *
  26.      * @return FormSchema|array
  27.      *
  28.      * @throws ResourceClassNotSupportedException
  29.      */
  30.     public function __invoke(Request $requeststring $id null)
  31.     {
  32.         $this->denyAccessUnlessGranted(SectionVoter::SECTION_ADD_EDIT);
  33.         return $this->sectionFormHandler->getSectionForm($id$request->get('customerId'));
  34.     }
  35. }