You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 line
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. }