<?php
namespace Oveleon\ContaoComponentStyleManager\EventSubscriber;
use Contao\CoreBundle\Routing\ScopeMatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class KernelRequestSubscriber implements EventSubscriberInterface
{
protected $scopeMatcher;
public function __construct(ScopeMatcher $scopeMatcher)
{
$this->scopeMatcher = $scopeMatcher;
}
public static function getSubscribedEvents()
{
return [KernelEvents::REQUEST => 'onKernelRequest'];
}
public function onKernelRequest(RequestEvent $e): void
{
$request = $e->getRequest();
if ($this->scopeMatcher->isBackendRequest($request)) {
$GLOBALS['TL_CSS'][] = 'bundles/contaocomponentstylemanager/stylemanager.css|static';
}
}
}