Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConsoleCommandEvent.php

class ConsoleCommandEvent

Allows to do things before the command is executed, like skipping the command or executing code before the command is going to be executed.

Changing the input arguments will have no effect.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Contracts\EventDispatcher\Event implements \Psr\EventDispatcher\StoppableEventInterface
    • class \Symfony\Component\Console\Event\ConsoleEvent extends \Symfony\Contracts\EventDispatcher\Event
      • class \Symfony\Component\Console\Event\ConsoleCommandEvent extends \Symfony\Component\Console\Event\ConsoleEvent

Expanded class hierarchy of ConsoleCommandEvent

2 files declare their use of ConsoleCommandEvent
Application.php in vendor/symfony/console/Application.php
ConsoleEvents.php in vendor/symfony/console/ConsoleEvents.php

File

vendor/symfony/console/Event/ConsoleCommandEvent.php, line 22

Namespace

Symfony\Component\Console\Event
View source
final class ConsoleCommandEvent extends ConsoleEvent {
    
    /**
     * The return code for skipped commands, this will also be passed into the terminate event.
     */
    public const RETURN_CODE_DISABLED = 113;
    
    /**
     * Indicates if the command should be run or skipped.
     */
    private bool $commandShouldRun = true;
    
    /**
     * Disables the command, so it won't be run.
     */
    public function disableCommand() : bool {
        return $this->commandShouldRun = false;
    }
    public function enableCommand() : bool {
        return $this->commandShouldRun = true;
    }
    
    /**
     * Returns true if the command is runnable, false otherwise.
     */
    public function commandShouldRun() : bool {
        return $this->commandShouldRun;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ConsoleCommandEvent::$commandShouldRun private property Indicates if the command should be run or skipped.
ConsoleCommandEvent::commandShouldRun public function Returns true if the command is runnable, false otherwise.
ConsoleCommandEvent::disableCommand public function Disables the command, so it won&#039;t be run.
ConsoleCommandEvent::enableCommand public function
ConsoleCommandEvent::RETURN_CODE_DISABLED public constant The return code for skipped commands, this will also be passed into the terminate event.
ConsoleEvent::getCommand public function Gets the command that is executed.
ConsoleEvent::getInput public function Gets the input instance.
ConsoleEvent::getOutput public function Gets the output instance.
ConsoleEvent::__construct public function 4
Event::$propagationStopped private property
Event::isPropagationStopped public function Is propagation stopped? Overrides StoppableEventInterface::isPropagationStopped
Event::stopPropagation public function Stops the propagation of the event to further event listeners. 1

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal