What is the event order in Drupal 8?
Submitted by clemens on Sat, 2014/10/11 - 1:59pm
For debugging the event order in core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php I needed to probe EventDispatcher::dispatch
This is needed for Enable CORS for GET requests which must respond regardless of permissions to an OPTIONS request.
# core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:103
class ContainerAwareEventDispatcher implements EventDispatcherInterface {
...
public function dispatch($event_name, Event $event = NULL) {
...
$listeners = $this->listeners[$event_name];
$list = array();
foreach($listeners as $prio => $services) {
foreach($services as $service) {
$list[] = "$prio " . $service['service'][0] . "::" . $service['service'][1];
}
}
$s = join("\n", $list);
This shows what events are called in order
kernel.request
1000 rest.options_subscriber::onKernelRequest
200 path_subscriber::onKernelRequestConvertPath
50 ajax_subscriber::onRequest
50 ajax.subscriber::onKernelRequest
40 hal.subscriber::onKernelRequest
35 user_maintenance_mode_subscriber::onKernelRequestMaintenance
32 router_listener::onKernelRequest
31 route_content_controller_subscriber::onRequestDeriveFormat
30 route_content_controller_subscriber::onRequestDeriveContentWrapper
30 maintenance_mode_subscriber::onKernelRequestMaintenance
29 route_content_form_controller_subscriber::onRequestDeriveFormWrapper
0 router.route_preloader::onRequest
0 replica_database_ignore__subscriber::checkReplicaServer
kernel.response
0 finish_response_subscriber::onRespond
0 redirect_response_subscriber::checkRedirectUrl
0 authentication_subscriber::onRespond
-100 ajax_subscriber::onResponse
kernel.finish_request
0 router_listener::onKernelFinishRequest