<?php

declare(strict_types=1);

namespace App\Twig;

use App\Entity\Ecole;
use App\Service\PublicUrlGenerator;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

final class PublicUrlExtension extends AbstractExtension
{
    public function __construct(private readonly PublicUrlGenerator $publicUrlGenerator)
    {
    }

    public function getFunctions(): array
    {
        return [
            new TwigFunction('public_school_url', fn (Ecole $ecole): string => $this->publicUrlGenerator->schoolUrl($ecole)),
            new TwigFunction('public_registration_url', fn (Ecole $ecole): string => $this->publicUrlGenerator->registrationUrl($ecole)),
            new TwigFunction('platform_public_url', fn (string $path = '/'): string => $this->publicUrlGenerator->platformUrl($path)),
            new TwigFunction('public_absolute_asset_url', fn (?Ecole $ecole, ?string $path): string => $this->publicUrlGenerator->absoluteAssetUrl($ecole, $path)),
        ];
    }
}
