public function FormTestEventSubscriber::onKernelRequest

Adds custom attributes to the request object.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The kernel request event.

File

drupal/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/EventSubscriber/FormTestEventSubscriber.php, line 25
Contains \Drupal\form_test\EventSubscriber\FormTestEventSubscriber.

Class

FormTestEventSubscriber
Test event subscriber to add new attributes to the request.

Namespace

Drupal\form_test\EventSubscriber

Code

public function onKernelRequest(GetResponseEvent $event) {
  $request = $event
    ->getRequest();
  $request->attributes
    ->set('custom_attributes', 'custom_value');
  $request->attributes
    ->set('request_attribute', 'request_value');
}