config = $config->get('devel.settings'); $this->account = $account; $this->themeHandler = $theme_handler; } /** * Forces the system to rebuild the theme registry. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The event to process. */ public function rebuildThemeInfo(GetResponseEvent $event) { if ($this->config->get('rebuild_theme')) { // Update the theme registry. drupal_theme_rebuild(); // Refresh theme data. $this->themeHandler->refreshInfo(); // Notify the user that the theme info are rebuilt on every request. $this->triggerWarningIfNeeded($event->getRequest()); } } /** * Notifies the user that the theme info are rebuilt on every request. * * The warning message is shown only to users with adequate permissions and * only once per session. * * @param \Symfony\Component\HttpFoundation\Request $request * The request. */ protected function triggerWarningIfNeeded(Request $request) { if ($this->account && $this->account->hasPermission('access devel information')) { $session = $request->getSession(); if (!$session->has($this->notificationFlag)) { $session->set($this->notificationFlag, TRUE); $message = $this->t('The theme information is being rebuilt on every request. Remember to turn off this feature on production websites.', [':url' => Url::fromRoute('devel.admin_settings')->toString()]); drupal_set_message($message, 'warning', TRUE); } } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { // Set high priority value to start as early as possible. $events[KernelEvents::REQUEST][] = ['rebuildThemeInfo', 256]; return $events; } }