<?php

namespace App\Twig\Runtime;

use App\Entity\Setting;
use Doctrine\ORM\EntityManagerInterface;
use Twig\Extension\RuntimeExtensionInterface;

class SettingExtensionRuntime implements RuntimeExtensionInterface
{
    public function __construct(private EntityManagerInterface $manager)
    {
        // Inject dependencies if needed
    }

    public function setting_fn($setting): string
    {
        $sett = $this->manager->getRepository(Setting::class)->findOneBy(["setting" => $setting]);
        if (!$sett || !$sett->getValue()) return "### Le paramètre $setting n'a pas été défini ###";
        return $sett->getValue();
    }
}
