You are here

function DevelCommands::codeLocate in Devel 8.2

Same name and namespace in other branches
  1. 8.3 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::codeLocate()
  2. 8 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::codeLocate()
  3. 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::codeLocate()

Get source code line for specified function or method.

2 calls to DevelCommands::codeLocate()
DevelCommands::event in src/Commands/DevelCommands.php
List implementations of a given event and optionally edit one.
DevelCommands::hook in src/Commands/DevelCommands.php
List implementations of a given hook and optionally edit one.

File

src/Commands/DevelCommands.php, line 211

Class

DevelCommands
For commands that are parts of modules, Drush expects to find commandfiles in __MODULE__/src/Commands, and the namespace is Drupal/__MODULE__/Commands.

Namespace

Drupal\devel\Commands

Code

function codeLocate($function_name) {

  // Get implementations in the .install files as well.
  include_once './core/includes/install.inc';
  drupal_load_updates();
  if (strpos($function_name, '::') === FALSE) {
    if (!function_exists($function_name)) {
      throw new \Exception(dt('Function not found'));
    }
    $reflect = new \ReflectionFunction($function_name);
  }
  else {
    list($class, $method) = explode('::', $function_name);
    if (!method_exists($class, $method)) {
      throw new \Exception(dt('Method not found'));
    }
    $reflect = new \ReflectionMethod($class, $method);
  }
  return array(
    'file' => $reflect
      ->getFileName(),
    'startline' => $reflect
      ->getStartLine(),
    'endline' => $reflect
      ->getEndLine(),
  );
}