0 follower

Final Class Yiisoft\Yii\Debug\Collector\Console\CommandCollector

InheritanceYiisoft\Yii\Debug\Collector\Console\CommandCollector
ImplementsYiisoft\Yii\Debug\Collector\SummaryCollectorInterface
Uses TraitsYiisoft\Yii\Debug\Collector\CollectorTrait

Constants

Hide inherited 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

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Yii\Debug\Collector\TimelineCollector $timelineCollector )
$timelineCollector Yiisoft\Yii\Debug\Collector\TimelineCollector

                public function __construct(
    private readonly TimelineCollector $timelineCollector
) {
}

            
collect() public method

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() ?? [],
    ];
}

            
getCollected() public method

public array getCollected ( )

                public function getCollected(): array
{
    return $this->commands;
}

            
getName() public method
public string getName ( )

                public function getName(): string
{
    return self::class;
}

            
getSummary() public method

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,
    ];
}

            
shutdown() public method
public void shutdown ( )

                public function shutdown(): void
{
    $this->reset();
    $this->isActive = false;
}

            
startup() public method
public void startup ( )

                public function startup(): void
{
    $this->isActive = true;
}