function 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 256
Class
- DevelCommands
- Class DevelCommands.
Namespace
Drupal\devel\CommandsCode
public 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 {
[$class, $method] = explode('::', $function_name);
if (!method_exists($class, $method)) {
throw new \Exception(dt('Method not found'));
}
$reflect = new \ReflectionMethod($class, $method);
}
return [
'file' => $reflect->getFileName(),
'startline' => $reflect->getStartLine(),
'endline' => $reflect->getEndLine(),
];
}