<?php
declare(strict_types=1);
namespace App\Form\EventListener\Search\MailTransport;
use App\Entity\Message\SmsInterface;
use App\Form\FormHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class AddStatusSubscriber extends FormHelper implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
}
public function preSetData(FormEvent $event): void
{
$choices = ['app.global.filter.status.choices.all' => null];
foreach (SmsInterface::SMS_STATES as $state) {
$choices['app.notification.state.' . $state] = $state;
}
$event->getForm()->add('status', ChoiceType::class, $this->getChoiceParameters(
'app.global.search.label.status',
self::PLACEHOLDER_NONE,
false,
[
'choices' => $choices,
'data' => null,
]
));
}
}