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

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.     /** @var FormFactoryInterface */
  18.     private $formFactory;
  19.     public function __construct(FormFactoryInterface $formFactory)
  20.     {
  21.         $this->formFactory $formFactory;
  22.     }
  23.     public function create(RequestConfiguration $requestConfigurationResourceInterface $resource): FormInterface
  24.     {
  25.         $formType = (string) $requestConfiguration->getFormType();
  26.         $formOptions $requestConfiguration->getFormOptions();
  27.         if ($requestConfiguration->isHtmlRequest()) {
  28.             return $this->formFactory->create($formType$resource$formOptions);
  29.         }
  30.         return $this->formFactory->createNamed(''$formType$resourcearray_merge($formOptions, ['csrf_protection' => false]));
  31.     }
  32. }