deblan.io-murph/src/EventSuscriber/SettingEventSubscriber.php

66 lines
1.7 KiB
PHP
Raw Normal View History

2021-05-02 20:41:06 +02:00
<?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\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
2021-05-02 21:29:33 +02:00
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
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-05-02 21:29:33 +02:00
$this->manager->init('blog_footer_p1', 'Pied de page', 'Soutiens', '');
$this->manager->init('blog_footer_p2', 'Pied de page', 'Signature', '');
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 21:29:33 +02:00
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,
],
]
);
}
2021-05-02 20:41:06 +02:00
}
}