summaryrefslogtreecommitdiff
path: root/vendor/symfony/console/Event/ConsoleCommandEvent.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/console/Event/ConsoleCommandEvent.php')
-rw-r--r--vendor/symfony/console/Event/ConsoleCommandEvent.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/symfony/console/Event/ConsoleCommandEvent.php b/vendor/symfony/console/Event/ConsoleCommandEvent.php
new file mode 100644
index 0000000..0757a23
--- /dev/null
+++ b/vendor/symfony/console/Event/ConsoleCommandEvent.php
@@ -0,0 +1,54 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Console\Event;
13
14/**
15 * Allows to do things before the command is executed, like skipping the command or executing code before the command is
16 * going to be executed.
17 *
18 * Changing the input arguments will have no effect.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22final class ConsoleCommandEvent extends ConsoleEvent
23{
24 /**
25 * The return code for skipped commands, this will also be passed into the terminate event.
26 */
27 public const RETURN_CODE_DISABLED = 113;
28
29 /**
30 * Indicates if the command should be run or skipped.
31 */
32 private bool $commandShouldRun = true;
33
34 /**
35 * Disables the command, so it won't be run.
36 */
37 public function disableCommand(): bool
38 {
39 return $this->commandShouldRun = false;
40 }
41
42 public function enableCommand(): bool
43 {
44 return $this->commandShouldRun = true;
45 }
46
47 /**
48 * Returns true if the command is runnable, false otherwise.
49 */
50 public function commandShouldRun(): bool
51 {
52 return $this->commandShouldRun;
53 }
54}