2021-05-02 20:41:06 +02:00
|
|
|
<?php
|
|
|
|
|
2022-03-10 21:52:14 +01:00
|
|
|
namespace App\EventSubscriber;
|
2021-05-02 20:41:06 +02:00
|
|
|
|
|
|
|
use App\Core\Event\Setting\SettingEvent;
|
2022-03-10 21:52:14 +01:00
|
|
|
use App\Core\EventSubscriber\SettingEventSubscriber as EventSubscriber;
|
2021-05-02 20:41:06 +02:00
|
|
|
use App\Core\Setting\SettingManager;
|
2021-05-02 22:12:39 +02:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
2021-05-02 21:29:33 +02:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
2021-05-12 16:13:03 +02:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
2022-03-18 15:03:37 +01:00
|
|
|
use App\Core\Form\FileManager\FilePickerType;
|
2021-05-02 20:41:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2021-06-05 12:41:31 +02:00
|
|
|
$this->manager->init('blog_footer', '🥾 Pied de page', 'Contenu', '');
|
2021-05-02 22:12:39 +02:00
|
|
|
|
2022-03-18 15:03:37 +01:00
|
|
|
$this->manager->init('avatar_image', '👦 Avatar', 'Image', '');
|
|
|
|
|
2021-05-02 22:47:40 +02:00
|
|
|
$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', '');
|
2021-05-12 16:10:38 +02:00
|
|
|
|
|
|
|
$this->manager->init('stats_umami_url', '📊 Statistiques', 'Adresse tableau de bord Umami', '');
|
2021-06-05 18:55:16 +02:00
|
|
|
$this->manager->init('stats_umami_tag', '📊 Statistiques', 'Script Umami', '');
|
2021-05-12 16:10:38 +02:00
|
|
|
|
2022-09-11 18:57:55 +02:00
|
|
|
$this->manager->init('post_author_description', '🖊️ Article', 'Description auteur', '');
|
2022-09-11 18:50:04 +02:00
|
|
|
|
2022-01-26 23:40:10 +01:00
|
|
|
// $this->manager->init('giphy_api_key', '🌐 API', 'Clé d\'API Giphy', '');
|
2021-05-02 20:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function onFormInit(SettingEvent $event)
|
|
|
|
{
|
|
|
|
$data = $event->getData();
|
|
|
|
$builder = $data['builder'];
|
|
|
|
$entity = $data['entity'];
|
|
|
|
|
2021-05-02 22:12:39 +02:00
|
|
|
if (in_array($entity->getCode(), ['email_sender', 'email_contact', 'email_comment'])) {
|
|
|
|
$builder->add(
|
|
|
|
'value',
|
|
|
|
EmailType::class,
|
|
|
|
[
|
|
|
|
'label' => $entity->getLabel(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-03-18 15:03:37 +01:00
|
|
|
if (in_array($entity->getCode(), ['avatar_image'])) {
|
|
|
|
$builder->add(
|
|
|
|
'value',
|
|
|
|
FilePickerType::class,
|
|
|
|
[
|
|
|
|
'label' => $entity->getLabel(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-05-12 16:13:03 +02:00
|
|
|
if (in_array($entity->getCode(), ['giphy_api_key', 'stats_umami_url'])) {
|
2021-05-02 21:29:33 +02:00
|
|
|
$builder->add(
|
|
|
|
'value',
|
2021-05-12 16:13:03 +02:00
|
|
|
TextType::class,
|
2021-05-02 21:29:33 +02:00
|
|
|
[
|
|
|
|
'label' => $entity->getLabel(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-05 18:55:16 +02:00
|
|
|
if (in_array($entity->getCode(), ['stats_umami_tag'])) {
|
2021-10-22 14:06:05 +02:00
|
|
|
$event->setOption('view', 'large');
|
|
|
|
|
2021-06-05 18:55:16 +02:00
|
|
|
$builder->add(
|
|
|
|
'value',
|
|
|
|
TextareaType::class,
|
|
|
|
[
|
|
|
|
'label' => $entity->getLabel(),
|
|
|
|
'attr' => [
|
|
|
|
'rows' => 3,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-11 18:50:04 +02:00
|
|
|
if (in_array($entity->getCode(), ['blog_footer', 'post_author_description'])) {
|
2021-10-22 14:06:05 +02:00
|
|
|
$event->setOption('view', 'large');
|
|
|
|
|
2021-05-02 21:29:33 +02:00
|
|
|
$builder->add(
|
|
|
|
'value',
|
|
|
|
TextareaType::class,
|
|
|
|
[
|
|
|
|
'label' => $entity->getLabel(),
|
|
|
|
'attr' => [
|
2021-06-05 12:41:31 +02:00
|
|
|
'rows' => 20,
|
2021-05-02 21:29:33 +02:00
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2021-05-02 20:41:06 +02:00
|
|
|
}
|
|
|
|
}
|