![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/plugins/GrapesJsBuilderBundle/EventSubscriber/ |
<?php declare(strict_types=1); namespace MauticPlugin\GrapesJsBuilderBundle\EventSubscriber; use Mautic\CoreBundle\CoreEvents; use Mautic\CoreBundle\Event\CustomAssetsEvent; use Mautic\InstallBundle\Install\InstallService; use MauticPlugin\GrapesJsBuilderBundle\Integration\Config; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RequestStack; class AssetsSubscriber implements EventSubscriberInterface { public function __construct( private Config $config, private InstallService $installer, private RequestStack $requestStack ) { } public static function getSubscribedEvents(): array { return [ CoreEvents::VIEW_INJECT_CUSTOM_ASSETS => ['injectAssets', 0], ]; } public function injectAssets(CustomAssetsEvent $assetsEvent): void { if (!$this->installer->checkIfInstalled() || !$this->isMauticAdministrationPage()) { return; } if ($this->config->isPublished()) { $assetsEvent->addScript('plugins/GrapesJsBuilderBundle/Assets/library/js/dist/builder.js'); $assetsEvent->addStylesheet('plugins/GrapesJsBuilderBundle/Assets/library/js/dist/builder.css'); } } /** * Returns true for routes that starts with /s/. */ private function isMauticAdministrationPage(): bool { return preg_match('/^\/s\//', $this->requestStack->getCurrentRequest()->getPathInfo()) >= 1; } }