vendor/sylius/resource-bundle/src/Bundle/Controller/ResourceFormFactory.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\ResourceBundle\Controller;
  12. use Sylius\Component\Resource\Model\ResourceInterface;
  13. use Symfony\Component\Form\FormFactoryInterface;
  14. use Symfony\Component\Form\FormInterface;
  15. final class ResourceFormFactory implements ResourceFormFactoryInterface
  16. {
  17.     private FormFactoryInterface $formFactory;
  18.     public function __construct(FormFactoryInterface $formFactory)
  19.     {
  20.         $this->formFactory $formFactory;
  21.     }
  22.     public function create(RequestConfiguration $requestConfigurationResourceInterface $resource): FormInterface
  23.     {
  24.         $formType = (string) $requestConfiguration->getFormType();
  25.         $formOptions $requestConfiguration->getFormOptions();
  26.         if ($requestConfiguration->isHtmlRequest()) {
  27.             return $this->formFactory->create($formType$resource$formOptions);
  28.         }
  29.         return $this->formFactory->createNamed(''$formType$resourcearray_merge($formOptions, ['csrf_protection' => false]));
  30.     }
  31. }