<?php

namespace AutoAdmin\Bundle\Content\EventListener;

use AutoAdmin\Bundle\Content\Configuration\ConfigManager;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Twig\Environment;

class TwigContentConfigListener
{
    /**
     * @var Environment
     */
    private $twig;
    /**
     * @var ConfigManager
     */
    private $configManager;

    public function __construct(Environment $twig, ConfigManager $configManager)
    {
        $this->twig = $twig;
        $this->configManager = $configManager;
    }

    public function onKernelController(ControllerEvent $event): void
    {
        $this->twig->addGlobal('aa_content_config', $this->configManager->getConfig());
    }
}