Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

StoreTwigExtension.php 1.4KB

3 lat temu
3 lat temu
3 lat temu
3 lat temu
3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Lc\SovBundle\Twig;
  3. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  4. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  5. use Lc\SovBundle\Model\Site\SiteInterface;
  6. use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface;
  7. use Lc\SovBundle\Solver\Setting\SettingSolver;
  8. use Symfony\Component\Security\Core\Security;
  9. use Twig\Extension\AbstractExtension;
  10. use Twig\TwigFunction;
  11. class StoreTwigExtension extends AbstractExtension
  12. {
  13. protected Security $security;
  14. protected ReminderStoreInterface $reminderStore;
  15. protected SettingSolver $settingSolver;
  16. public function __construct(
  17. Security $security,
  18. ReminderStoreInterface $reminderStore,
  19. SettingSolver $settingSolver
  20. ) {
  21. $this->security = $security;
  22. $this->reminderStore = $reminderStore;
  23. $this->settingSolver = $settingSolver;
  24. }
  25. public function getFunctions()
  26. {
  27. return [
  28. new TwigFunction('sov_reminders', [$this, 'getReminders']),
  29. new TwigFunction('site_setting', [$this, 'getSiteSetting']),
  30. ];
  31. }
  32. public function getFilters()
  33. {
  34. return [];
  35. }
  36. public function getSiteSetting(SiteInterface $site, string $settingName): ?string
  37. {
  38. return $this->settingSolver->getSettingValue($site, $settingName);
  39. }
  40. public function getReminders($params)
  41. {
  42. // @TODO : à faire
  43. return array();
  44. }
  45. }