You are here

protected function ThemeInfoRebuildSubscriber::triggerWarningIfNeeded in Devel 8.3

Same name and namespace in other branches
  1. 8 src/EventSubscriber/ThemeInfoRebuildSubscriber.php \Drupal\devel\EventSubscriber\ThemeInfoRebuildSubscriber::triggerWarningIfNeeded()
  2. 8.2 src/EventSubscriber/ThemeInfoRebuildSubscriber.php \Drupal\devel\EventSubscriber\ThemeInfoRebuildSubscriber::triggerWarningIfNeeded()
  3. 4.x src/EventSubscriber/ThemeInfoRebuildSubscriber.php \Drupal\devel\EventSubscriber\ThemeInfoRebuildSubscriber::triggerWarningIfNeeded()

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.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

1 call to ThemeInfoRebuildSubscriber::triggerWarningIfNeeded()
ThemeInfoRebuildSubscriber::rebuildThemeInfo in src/EventSubscriber/ThemeInfoRebuildSubscriber.php
Forces the system to rebuild the theme registry.

File

src/EventSubscriber/ThemeInfoRebuildSubscriber.php, line 98

Class

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

Namespace

Drupal\devel\EventSubscriber

Code

protected function triggerWarningIfNeeded(Request $request) {
  if ($this->account && $this->account
    ->hasPermission('access devel information')) {
    $session = $request
      ->getSession();
    if ($session && !$session
      ->has($this->notificationFlag)) {
      $session
        ->set($this->notificationFlag, TRUE);
      $message = $this
        ->t('The theme information is being rebuilt on every request. Remember to <a href=":url">turn off</a> this feature on production websites.', [
        ':url' => Url::fromRoute('devel.admin_settings')
          ->toString(),
      ]);
      $this
        ->messenger()
        ->addWarning($message);
    }
  }
}