You are here

public function DevelCommands::hook in Devel 8.3

Same name and namespace in other branches
  1. 8 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hook()
  2. 8.2 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hook()
  3. 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\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();
}