You are here

function drush_devel_fn_event in Devel 8.2

Same name and namespace in other branches
  1. 8.3 drush/devel.drush8.inc \drush_devel_fn_event()
  2. 8 drush/devel.drush8.inc \drush_devel_fn_event()

Command handler. Show hook implementations.

File

drush/devel.drush8.inc, line 144
This file is only used by Drush8.

Code

function drush_devel_fn_event($event = NULL) {
  $dispatcher = Drupal::service('event_dispatcher');
  if (empty($event)) {
    $events = [
      'kernel.controller',
      'kernel.exception',
      'kernel.request',
      'kernel.response',
      'kernel.terminate',
      'kernel.view',
    ];
    $events = array_combine($events, $events);
    if (!($event = drush_choice($events, 'Enter the event you wish to explore.'))) {
      return drush_user_abort();
    }
  }
  if ($implementations = $dispatcher
    ->getListeners($event)) {
    foreach ($implementations as $implementation) {
      $callable = get_class($implementation[0]) . '::' . $implementation[1];
      $choices[$callable] = $callable;
    }
    if ($choice = drush_choice($choices, 'Enter the number of the implementation you wish to view.')) {
      return drush_devel_fn_view($choice);
    }
  }
  else {
    drush_log(dt('No implementations.'), 'ok');
  }
}