<?php
declare(strict_types=1);
namespace App\Form\EventListener\Admin\PaymentMethod\Gateway;
use App\Form\Admin\PaymentMethod\GatewayCustomType;
use App\Form\Admin\PaymentMethod\GlobalGatewayCustomType;
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 AddConfigurationFieldSubscriber extends FormHelper implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
}
public function preSetData(FormEvent $event): void
{
$event->getForm()->add('config', CollectionType::class, $this->getCollectionParameters(
GatewayCustomType::class,
['label' => false],
false
));
$event->getForm()->add('globalConfig', CollectionType::class, $this->getCollectionParameters(
GlobalGatewayCustomType::class,
['label' => false],
false
));
}
}