function DevelCommands::hook

List implementations of a given hook and optionally edit one.

@command devel:hook

@usage devel-hook cron List implementations of hook_cron(). @aliases fnh,fn-hook,hook,devel-hook @optionset_get_editor

Parameters

string $hook: The name of the hook to explore.

string $implementation: The name of the implementation to edit. Usually omitted.

File

src/Commands/DevelCommands.php, line 118

Class

DevelCommands
Class DevelCommands.

Namespace

Drupal\devel\Commands

Code

public function hook($hook, $implementation) {
  // Get implementations in the .install files as well.
  include_once './core/includes/install.inc';
  drupal_load_updates();
  $info = $this->codeLocate($implementation . "_{$hook}");
  $exec = self::getEditor();
  $cmd = sprintf($exec, Escape::shellArg($info['file']));
  $process = $this->processManager()
    ->shell($cmd);
  $process->setTty(TRUE);
  $process->mustRun();
}