function ThemeInfoRebuildSubscriber::rebuildThemeInfo

Same name in other branches
  1. 4.x src/EventSubscriber/ThemeInfoRebuildSubscriber.php \Drupal\devel\EventSubscriber\ThemeInfoRebuildSubscriber::rebuildThemeInfo()

Forces the system to rebuild the theme registry.

Parameters

\Symfony\Component\HttpKernel\Event\RequestEvent $event: The event to process.

File

src/EventSubscriber/ThemeInfoRebuildSubscriber.php, line 94

Class

ThemeInfoRebuildSubscriber
Subscriber for force the system to rebuild the theme registry.

Namespace

Drupal\devel\EventSubscriber

Code

public function rebuildThemeInfo(RequestEvent $event) : void {
    if ($this->config
        ->get('rebuild_theme')) {
        // Update the theme registry.
        $this->themeRegistry
            ->reset();
        // Refresh theme data.
        $this->themeHandler
            ->refreshInfo();
        // Resets the internal state of the theme handler and clear the 'system
        // list' cache; this allow to properly register, if needed, PSR-4
        // namespaces for theme extensions after refreshing the info data.
        $this->themeHandler
            ->reset();
        // Notify the user that the theme info are rebuilt on every request.
        $this->triggerWarningIfNeeded($event->getRequest());
    }
}