<?php

namespace Lc\SovBundle\Twig;

use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class StoreTwigExtension extends AbstractExtension
{
    protected Security $security;
    protected ReminderStoreInterface $reminderStore;

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

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

    public function getFilters()
    {
        return [];
    }

    public function getReminders($params)
    {
        return $this->reminderStore->get(array_merge(
                [
                        'user' => $this->security->getUser()
                ], $params)
        );
    }

}
