function DevelCommands::hook

Same name in other branches
  1. 5.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hook()
  2. 5.x src/Drush/Commands/DevelCommands.php \Drupal\devel\Drush\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();
}