function FormTestEventSubscriber::onKernelRequest
Same name in other branches
- 9 core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php \Drupal\form_test\EventSubscriber\FormTestEventSubscriber::onKernelRequest()
- 8.9.x core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php \Drupal\form_test\EventSubscriber\FormTestEventSubscriber::onKernelRequest()
- 10 core/modules/system/tests/modules/form_test/src/EventSubscriber/FormTestEventSubscriber.php \Drupal\form_test\EventSubscriber\FormTestEventSubscriber::onKernelRequest()
Adds custom attributes to the request object.
Parameters
\Symfony\Component\HttpKernel\Event\RequestEvent $event: The kernel request event.
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ EventSubscriber/ FormTestEventSubscriber.php, line 23
Class
- FormTestEventSubscriber
- Test event subscriber to add new attributes to the request.
Namespace
Drupal\form_test\EventSubscriberCode
public function onKernelRequest(RequestEvent $event) {
$request = $event->getRequest();
$request->attributes
->set('custom_attributes', 'custom_value');
$request->attributes
->set('request_attribute', 'request_value');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.