<?php
declare(strict_types=1);
namespace App\Form\EventListener\Admin\Webhook;
use App\Entity\Admin\Webhook\WebhookInterface;
use App\Form\Admin\EndpointType;
use App\Form\FormHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class AddEndpointsFieldSubscriber extends FormHelper implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
}
public function preSetData(FormEvent $event): void
{
$event->getForm()->add('endpoints', CollectionType::class, $this->getCollectionParameters(
EndpointType::class,
[
'label' => false,
],
false,
WebhookInterface::WEBHOOK_PROTOTYPE_NAME
));
}
}