<?php
declare(strict_types=1);
namespace App\Form\EventListener\User;
use App\Entity\Security\Customer;
use App\Form\FormHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class AddNotificationPhoneFieldSubscriber extends FormHelper implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
}
public function preSetData(FormEvent $event): void
{
$user = $event->getData();
if (false === $user instanceof Customer) {
return;
}
$event->getForm()->add('notificationSms', CheckboxType::class, $this->getCheckParameters('app.global.user.list.notification_sms', self::PLACEHOLDER_ENABLE_ASK));
}
}