Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

53 lines
1.3KB

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