src/Form/EventListener/Admin/Webhook/AddEndpointsFieldSubscriber.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Form\EventListener\Admin\Webhook;
  4. use App\Entity\Admin\Webhook\WebhookInterface;
  5. use App\Form\Admin\EndpointType;
  6. use App\Form\FormHelper;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  9. use Symfony\Component\Form\FormEvent;
  10. use Symfony\Component\Form\FormEvents;
  11. class AddEndpointsFieldSubscriber extends FormHelper implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [FormEvents::PRE_SET_DATA => 'preSetData'];
  16.     }
  17.     public function preSetData(FormEvent $event): void
  18.     {
  19.         $event->getForm()->add('endpoints'CollectionType::class, $this->getCollectionParameters(
  20.             EndpointType::class,
  21.             [
  22.                 'label' => false,
  23.             ],
  24.             false,
  25.             WebhookInterface::WEBHOOK_PROTOTYPE_NAME
  26.         ));
  27.     }
  28. }