public function collectRuntimeJavaScripts(CollectAssetsEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
 {
     if ($eventName == ThemePlusEvents::COLLECT_HEAD_JAVASCRIPT_ASSETS && $event->getLayout()->theme_plus_default_javascript_position != 'head' || $eventName == ThemePlusEvents::COLLECT_BODY_JAVASCRIPT_ASSETS && $event->getLayout()->theme_plus_default_javascript_position != 'body') {
         return;
     }
     if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT'])) {
         foreach ($GLOBALS['TL_JAVASCRIPT'] as $javaScript) {
             if ($javaScript instanceof AssetInterface) {
                 $event->append($javaScript);
             } else {
                 list($javaScript, $mode) = explode('|', $javaScript);
                 $stripStaticDomainEvent = new StripStaticDomainEvent($event->getRenderMode(), $event->getPage(), $event->getLayout(), $javaScript);
                 $eventDispatcher->dispatch(ThemePlusEvents::STRIP_STATIC_DOMAIN, $stripStaticDomainEvent);
                 $javaScript = $stripStaticDomainEvent->getUrl();
                 $asset = new ExtendedFileAsset(TL_ROOT . '/' . $javaScript, [], TL_ROOT, $javaScript);
                 $asset->setStandalone($mode != 'static');
                 $generateAssetPathEvent = new GenerateAssetPathEvent($event->getRenderMode(), $event->getPage(), $event->getLayout(), $asset, $event->getDefaultFilters(), 'js');
                 $eventDispatcher->dispatch(ThemePlusEvents::GENERATE_ASSET_PATH, $generateAssetPathEvent);
                 $asset->setTargetPath($generateAssetPathEvent->getPath());
                 $event->append($asset);
             }
         }
         $GLOBALS['TL_JAVASCRIPT'] = [];
     }
 }
 public function collectUserStylesheets(CollectAssetsEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
 {
     if (is_array($GLOBALS['TL_USER_CSS']) && !empty($GLOBALS['TL_USER_CSS'])) {
         foreach ($GLOBALS['TL_USER_CSS'] as $stylesheet) {
             if ($stylesheet instanceof AssetInterface) {
                 $event->append($stylesheet);
             } else {
                 list($source, $media, $mode, $version) = explode('|', $stylesheet);
                 $stripStaticDomainEvent = new StripStaticDomainEvent($event->getRenderMode(), $event->getPage(), $event->getLayout(), $source);
                 $eventDispatcher->dispatch(ThemePlusEvents::STRIP_STATIC_DOMAIN, $stripStaticDomainEvent);
                 $source = $stripStaticDomainEvent->getUrl();
                 $asset = new ExtendedFileAsset(TL_ROOT . '/' . $source, [new CssRewriteFilter()], TL_ROOT, $stylesheet);
                 $asset->setMediaQuery($media);
                 $asset->setStandalone($mode != 'static');
                 $generateAssetPathEvent = new GenerateAssetPathEvent($event->getRenderMode(), $event->getPage(), $event->getLayout(), $asset, $event->getDefaultFilters(), 'css');
                 $eventDispatcher->dispatch(ThemePlusEvents::GENERATE_ASSET_PATH, $generateAssetPathEvent);
                 $asset->setTargetPath($generateAssetPathEvent->getPath());
                 $event->append($asset, 150);
             }
         }
         $GLOBALS['TL_USER_CSS'] = [];
     }
 }