You are here

public function RequestSubscriber::onRequest in Lightning API 8.3

Same name and namespace in other branches
  1. 8.4 src/RequestSubscriber.php \Drupal\lightning_api\RequestSubscriber::onRequest()
  2. 8 src/RequestSubscriber.php \Drupal\lightning_api\RequestSubscriber::onRequest()
  3. 8.2 src/RequestSubscriber.php \Drupal\lightning_api\RequestSubscriber::onRequest()

Reacts to an incoming request.

File

src/RequestSubscriber.php, line 63

Class

RequestSubscriber
Reacts to incoming HTTP requests.

Namespace

Drupal\lightning_api

Code

public function onRequest() {
  if ($this->routeMatch
    ->getRouteName() == 'oauth2_token.settings' && $this->key
    ->exists() == FALSE) {
    $warning = $this
      ->t('You may wish to <a href=":generate_keys">generate a key pair</a> for OAuth authentication.', [
      ':generate_keys' => Url::fromRoute('lightning_api.generate_keys')
        ->toString(),
    ]);
    $this
      ->messenger()
      ->addWarning($warning);
  }
}