78 lines
2.2 KiB
PHP
78 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\EventSuscriber;
|
|
|
|
use App\Core\Event\Setting\SettingEvent;
|
|
use App\Core\EventSuscriber\SettingEventSubscriber as EventSubscriber;
|
|
use App\Core\Setting\SettingManager;
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
|
|
/**
|
|
* class SettingEventSubscriber.
|
|
*
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
*/
|
|
class SettingEventSubscriber extends EventSubscriber
|
|
{
|
|
protected SettingManager $manager;
|
|
|
|
public function __construct(SettingManager $manager)
|
|
{
|
|
$this->manager = $manager;
|
|
}
|
|
|
|
public function onInit(SettingEvent $event)
|
|
{
|
|
$this->manager->init('blog_footer_p1', '🥾 Pied de page', 'Soutiens', '');
|
|
$this->manager->init('blog_footer_p2', '🥾 Pied de page', 'Signature', '');
|
|
|
|
$this->manager->init('email_sender', '🤖 E-mail', 'Expéditeur', '');
|
|
$this->manager->init('email_contact', '🤖 E-mail', 'Destinataire formulaire de contact', '');
|
|
$this->manager->init('email_comment', '🤖 E-mail', 'Destinataire nouveau commentaire', '');
|
|
}
|
|
|
|
public function onFormInit(SettingEvent $event)
|
|
{
|
|
$data = $event->getData();
|
|
$builder = $data['builder'];
|
|
$entity = $data['entity'];
|
|
|
|
if (in_array($entity->getCode(), ['email_sender', 'email_contact', 'email_comment'])) {
|
|
$builder->add(
|
|
'value',
|
|
EmailType::class,
|
|
[
|
|
'label' => $entity->getLabel(),
|
|
]
|
|
);
|
|
}
|
|
|
|
if ('blog_footer_p1' === $entity->getCode()) {
|
|
$builder->add(
|
|
'value',
|
|
TextareaType::class,
|
|
[
|
|
'label' => $entity->getLabel(),
|
|
'attr' => [
|
|
'rows' => 10,
|
|
],
|
|
]
|
|
);
|
|
}
|
|
|
|
if ('blog_footer_p2' === $entity->getCode()) {
|
|
$builder->add(
|
|
'value',
|
|
TextareaType::class,
|
|
[
|
|
'label' => $entity->getLabel(),
|
|
'attr' => [
|
|
'rows' => 10,
|
|
],
|
|
]
|
|
);
|
|
}
|
|
}
|
|
}
|