浏览代码

Merge branch 'develop'

master
Guillaume 3 年前
父节点
当前提交
3e24784b12
共有 3 个文件被更改,包括 21 次插入1 次删除
  1. +1
    -0
      Resources/views/admin/setting/form.html.twig
  2. +14
    -1
      Twig/StoreTwigExtension.php
  3. +6
    -0
      Twig/TwigExtension.php

+ 1
- 0
Resources/views/admin/setting/form.html.twig 查看文件

@@ -47,5 +47,6 @@
{% do form.settings.setRendered %}

{{ form_end(form) }}

{% endblock %}
{% endembed %}

+ 14
- 1
Twig/StoreTwigExtension.php 查看文件

@@ -3,7 +3,10 @@
namespace Lc\SovBundle\Twig;

use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Site\SiteInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
@@ -12,19 +15,24 @@ class StoreTwigExtension extends AbstractExtension
{
protected Security $security;
protected ReminderStoreInterface $reminderStore;
protected SettingSolver $settingSolver;

public function __construct(
Security $security,
ReminderStoreInterface $reminderStore
ReminderStoreInterface $reminderStore,
SettingSolver $settingSolver
) {
$this->security = $security;
$this->reminderStore = $reminderStore;
$this->settingSolver = $settingSolver;
}

public function getFunctions()
{
return [
new TwigFunction('sov_reminders', [$this, 'getReminders']),
new TwigFunction('site_setting', [$this, 'getSiteSetting']),

];
}

@@ -33,6 +41,11 @@ class StoreTwigExtension extends AbstractExtension
return [];
}

public function getSiteSetting(SiteInterface $site, string $settingName): ?string
{
return $this->settingSolver->getSettingValue($site, $settingName);
}

public function getReminders($params)
{
// @TODO : à faire

+ 6
- 0
Twig/TwigExtension.php 查看文件

@@ -114,9 +114,15 @@ class TwigExtension extends AbstractExtension
new TwigFilter('sov_cache', [$this, 'sovCache']),
new TwigFilter('slugify', [$this, 'slugify']),
new TwigFilter('md5', [$this, 'md5']),
new TwigFilter('rot13', [$this, 'rot13']),
];
}

public function rot13(string $string): string
{
return str_rot13($string);
}

public function isInstanceOf(EntityInterface $entity, string $interfaceName)
{
$reflection = new \ReflectionClass($entity);

正在加载...
取消
保存