Final Class Yiisoft\Yii\Debug\Api\Inspector\Command\BashCommand
| Inheritance | Yiisoft\Yii\Debug\Api\Inspector\Command\BashCommand |
|---|---|
| Implements | Yiisoft\Yii\Debug\Api\Inspector\CommandInterface |
Public Methods
Method Details
| public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases, array $command ) | ||
| $aliases | \Yiisoft\Aliases\Aliases | |
| $command | array | |
public function __construct(
private Aliases $aliases,
private array $command,
) {
}
| public static string getDescription ( ) |
public static function getDescription(): string
{
return 'Runs any commands from the project root.';
}
| public Yiisoft\Yii\Debug\Api\Inspector\CommandResponse run ( ) |
public function run(): CommandResponse
{
$projectDirectory = $this->aliases->get('@root');
$process = new Process($this->command);
$process
->setWorkingDirectory($projectDirectory)
->setTimeout(null)
->run();
$processOutput = rtrim($process->getOutput());
if (!$process->getExitCode() > 1) {
return new CommandResponse(
status: CommandResponse::STATUS_FAIL,
result: null,
errors: array_filter([$processOutput, $process->getErrorOutput()]),
);
}
return new CommandResponse(
status: $process->isSuccessful() ? CommandResponse::STATUS_OK : CommandResponse::STATUS_ERROR,
result: $processOutput . $process->getErrorOutput()
);
}
Signup or Login in order to comment.