backports murph-skeleton
This commit is contained in:
parent
ef0ddbd559
commit
2670c322e6
34
core/Twig/Extension/SettingExtension.php
Normal file
34
core/Twig/Extension/SettingExtension.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Twig\Extension;
|
||||||
|
|
||||||
|
use App\Core\Setting\SettingManager;
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
class SettingExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
private SettingManager $manager;
|
||||||
|
|
||||||
|
public function __construct(SettingManager $manager)
|
||||||
|
{
|
||||||
|
$this->manager = $manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getFunctions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new TwigFunction('setting', [$this, 'getSetting']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSetting(string $code)
|
||||||
|
{
|
||||||
|
$entity = $this->manager->get($code);
|
||||||
|
|
||||||
|
return $entity ? $entity->getValue() : null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ use App\Core\EventSuscriber\SettingEventSubscriber as EventSubscriber;
|
||||||
use App\Core\Setting\SettingManager;
|
use App\Core\Setting\SettingManager;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class SettingEventSubscriber.
|
* class SettingEventSubscriber.
|
||||||
|
@ -24,8 +25,8 @@ class SettingEventSubscriber extends EventSubscriber
|
||||||
|
|
||||||
public function onInit(SettingEvent $event)
|
public function onInit(SettingEvent $event)
|
||||||
{
|
{
|
||||||
// $this->manager->init('myapp_foo', 'My app', 'Foo', 'Default value');
|
$this->manager->init('blog_footer_p1', 'Pied de page', 'Soutiens', '');
|
||||||
// $this->manager->init('myapp_bar', 'My app', 'Bar', true);
|
$this->manager->init('blog_footer_p2', 'Pied de page', 'Signature', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onFormInit(SettingEvent $event)
|
public function onFormInit(SettingEvent $event)
|
||||||
|
@ -34,25 +35,31 @@ class SettingEventSubscriber extends EventSubscriber
|
||||||
$builder = $data['builder'];
|
$builder = $data['builder'];
|
||||||
$entity = $data['entity'];
|
$entity = $data['entity'];
|
||||||
|
|
||||||
// if ('myapp_foo' === $entity->getCode()) {
|
if ('blog_footer_p1' === $entity->getCode()) {
|
||||||
// $builder->add(
|
$builder->add(
|
||||||
// 'value',
|
'value',
|
||||||
// TextType::class,
|
TextareaType::class,
|
||||||
// [
|
[
|
||||||
// 'label' => $entity->getLabel(),
|
'label' => $entity->getLabel(),
|
||||||
// ]
|
'attr' => [
|
||||||
// );
|
'rows' => 10,
|
||||||
// }
|
],
|
||||||
//
|
]
|
||||||
// if ('myapp_bar' === $entity->getCode()) {
|
);
|
||||||
// $builder->add(
|
}
|
||||||
// 'value',
|
|
||||||
// CheckboxType::class,
|
if ('blog_footer_p2' === $entity->getCode()) {
|
||||||
// [
|
$builder->add(
|
||||||
// 'label' => $entity->getLabel(),
|
'value',
|
||||||
// 'required' => false,
|
TextareaType::class,
|
||||||
// ]
|
[
|
||||||
// );
|
'label' => $entity->getLabel(),
|
||||||
// }
|
'attr' => [
|
||||||
|
'rows' => 10,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,13 +109,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% set c %}Je soutiens <a href="https://www.tinternet.net/">Tinternet & cie</a>, les <a href="https://chatons.org/">Chatons</a> et l'<a href="https://www.april.org/">April</a>{% endset %}
|
|
||||||
|
|
||||||
<div class="col-12 content-footer">
|
<div class="col-12 content-footer">
|
||||||
<p>{{- c|raw -}}</p>
|
<p>{{- setting('blog_footer_p1')|raw -}}</p>
|
||||||
<ul class="list--inline">
|
<ul class="list--inline">
|
||||||
<li>Simon Vieille</li>
|
{%- for item in setting('blog_footer_p2')|split("\n") -%}
|
||||||
<li>Textes libres sauf indication(s) contraire(s)</li>
|
<li>{{- item|trim|raw -}}</li>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% for item in _navigation.menu('footer').rootNode.children %}
|
{% for item in _navigation.menu('footer').rootNode.children %}
|
||||||
{% if item.isVisible and item.treeLevel == 1 %}
|
{% if item.isVisible and item.treeLevel == 1 %}
|
||||||
|
|
Loading…
Reference in a new issue