<?php

namespace Modules\Stock\TwigExtension;

use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class AssetsExtension extends AbstractExtension
{
    public function __construct(private readonly ContainerInterface $contenaire)
    {
    }

    public function getFunctions(): array
    {
        return [
            new TwigFunction('assets', [$this, 'getAssets']),
        ];
    }

    /**
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getAssets(string $filePath): string
    {
        return $this->contenaire->get('baseUrl') . $filePath;
    }
}
