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.

StoreTwigExtension.php 1.0KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Lc\SovBundle\Twig;
  3. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  4. use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface;
  5. use Symfony\Component\Security\Core\Security;
  6. use Twig\Extension\AbstractExtension;
  7. use Twig\TwigFunction;
  8. class StoreTwigExtension extends AbstractExtension
  9. {
  10. protected Security $security;
  11. protected ReminderStoreInterface $reminderStore;
  12. public function __construct(
  13. Security $security,
  14. ReminderStoreInterface $reminderStore
  15. ) {
  16. $this->security = $security;
  17. $this->reminderStore = $reminderStore;
  18. }
  19. public function getFunctions()
  20. {
  21. return [
  22. new TwigFunction('sov_reminders', [$this, 'getReminders']),
  23. ];
  24. }
  25. public function getFilters()
  26. {
  27. return [];
  28. }
  29. public function getReminders($params)
  30. {
  31. return $this->reminderStore->get(array_merge(
  32. [
  33. 'user' => $this->security->getUser()
  34. ], $params)
  35. );
  36. }
  37. }