This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php

52 lines
1.2 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Console\Event;
/**
* Allows to do things before the command is executed, like skipping the command or changing the input.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
2019-08-23 00:03:38 +01:00
final class ConsoleCommandEvent extends ConsoleEvent
{
/**
2015-08-24 07:53:33 +01:00
* The return code for skipped commands, this will also be passed into the terminate event.
*/
const RETURN_CODE_DISABLED = 113;
/**
2015-08-24 07:53:33 +01:00
* Indicates if the command should be run or skipped.
*/
private $commandShouldRun = true;
/**
2015-08-24 07:53:33 +01:00
* Disables the command, so it won't be run.
*/
2019-08-23 00:03:38 +01:00
public function disableCommand(): bool
{
return $this->commandShouldRun = false;
}
2019-08-23 00:03:38 +01:00
public function enableCommand(): bool
{
return $this->commandShouldRun = true;
}
/**
2015-08-24 07:53:33 +01:00
* Returns true if the command is runnable, false otherwise.
*/
2019-08-23 00:03:38 +01:00
public function commandShouldRun(): bool
{
return $this->commandShouldRun;
}
}