Final Class Yiisoft\Yii\Debug\Collector\Console\CommandCollector
| Inheritance | Yiisoft\Yii\Debug\Collector\Console\CommandCollector |
|---|---|
| Implements | Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface |
| Uses Traits | Yiisoft\Yii\Debug\Collector\CollectorTrait |
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| UNDEFINED_EXIT_CODE | -1 | Let -1 mean that it was not set during the process. | Yiisoft\Yii\Debug\Collector\Console\CommandCollector |
Method Details
| public mixed __construct ( Yiisoft\Yii\Debug\Collector\TimelineCollector $timelineCollector ) | ||
| $timelineCollector | Yiisoft\Yii\Debug\Collector\TimelineCollector | |
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}
| public void collect ( \Symfony\Component\Console\Event\ConsoleEvent|\Symfony\Component\Console\Event\ConsoleErrorEvent|\Symfony\Component\Console\Event\ConsoleTerminateEvent $event ) | ||
| $event | \Symfony\Component\Console\Event\ConsoleEvent|\Symfony\Component\Console\Event\ConsoleErrorEvent|\Symfony\Component\Console\Event\ConsoleTerminateEvent | |
public function collect(ConsoleEvent|ConsoleErrorEvent|ConsoleTerminateEvent $event): void
{
if (!$this->isActive()) {
return;
}
$this->timelineCollector->collect($this, spl_object_id($event));
$command = $event->getCommand();
if ($event instanceof ConsoleErrorEvent) {
$this->commands[$event::class] = [
'name' => $event->getInput()->getFirstArgument() ?? '',
'command' => $command,
'input' => $this->castInputToString($event->getInput()),
'output' => $this->fetchOutput($event->getOutput()),
'error' => $event->getError()->getMessage(),
'exitCode' => $event->getExitCode(),
];
return;
}
if ($event instanceof ConsoleTerminateEvent) {
$this->commands[$event::class] = [
'name' => $command?->getName() ?? $event->getInput()->getFirstArgument() ?? '',
'command' => $command,
'input' => $this->castInputToString($event->getInput()),
'output' => $this->fetchOutput($event->getOutput()),
'exitCode' => $event->getExitCode(),
];
return;
}
$definition = $command?->getDefinition();
$this->commands[$event::class] = [
'name' => $command?->getName() ?? $event->getInput()->getFirstArgument() ?? '',
'command' => $command,
'input' => $this->castInputToString($event->getInput()),
'output' => $this->fetchOutput($event->getOutput()),
'arguments' => $definition?->getArguments() ?? [],
'options' => $definition?->getOptions() ?? [],
];
}
| public array getSummary ( ) |
public function getSummary(): array
{
if (empty($this->commands)) {
return [];
}
$eventTypes = $this->getSupportedEvents();
$commandEvent = null;
foreach ($eventTypes as $eventType) {
if (!array_key_exists($eventType, $this->commands)) {
continue;
}
$commandEvent = $this->commands[$eventType];
break;
}
if ($commandEvent === null) {
return [];
}
return [
'name' => $commandEvent['name'],
'class' => $commandEvent['command'] instanceof Command ? $commandEvent['command']::class : null,
'input' => $commandEvent['input'],
'exitCode' => $commandEvent['exitCode'] ?? self::UNDEFINED_EXIT_CODE,
];
}
| public void shutdown ( ) |
public function shutdown(): void
{
$this->reset();
$this->isActive = false;
}
Signup or Login in order to comment.