function CodeLocationTrait::edit
Opens a file in the user's editor.
An editor needs a terminal. Without one, the location is printed instead.
Parameters
\Symfony\Component\Console\Input\InputInterface $input: The input.
\Symfony\Component\Console\Output\OutputInterface $output: The output.
array{file: string, line: int} $location: A location, as returned by ::locate().
string $editor: A string of bash which launches a text editor.
2 calls to CodeLocationTrait::edit()
- DevelEventCommand::__invoke in src/
Command/ DevelEventCommand.php - Lists the listeners of an event, or opens one of them in an editor.
- DevelHookCommand::__invoke in src/
Command/ DevelHookCommand.php - Lists the implementations of a hook, or opens one of them in an editor.
File
-
src/
Command/ CodeLocationTrait.php, line 50
Class
- CodeLocationTrait
- Locates the source code of callables and opens it in an editor.
Namespace
Drupal\devel\CommandCode
protected function edit(InputInterface $input, OutputInterface $output, array $location, string $editor) : void {
if (!$input->isInteractive() || !Process::isTtySupported()) {
$output->writeln($location['file'] . ':' . $location['line']);
return;
}
$process = Process::fromShellCommandline($editor . ' "${:DEVEL_FILE}"', timeout: NULL);
$process->setTty(TRUE);
$process->mustRun(env: [
'DEVEL_FILE' => $location['file'],
]);
}