<?php
declare(strict_types=1);
/*
* This file is part of Custom Article for Contao Open Source CMS.
*
* (c) Christian Romeni
*
* @license LGPL-3.0-or-later
*/
namespace Rwd\ContaoCustomArticlesBundle\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(): array
{
return [KernelEvents::REQUEST => 'onKernelRequest'];
}
public function onKernelRequest(RequestEvent $e): void
{
$request = $e->getRequest();
if ($this->scopeMatcher->isBackendRequest($request)) {
$GLOBALS['TL_CSS'][] = '/bundles/contaocustomarticles/assets/extend-backend.css|static';
}
}
}