1 | <?php |
||
16 | class SilverstripeApplication extends SymfonyApplication |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * The output from the previous command. |
||
20 | * |
||
21 | * @var \Symfony\Component\Console\Output\BufferedOutput |
||
22 | */ |
||
23 | protected $lastOutput; |
||
24 | |||
25 | public function __construct() |
||
26 | { |
||
27 | parent::__construct(); |
||
28 | |||
29 | $this->loadCommands(); |
||
30 | |||
31 | $this->add($default = new DefaultCommand()); |
||
32 | $this->setDefaultCommand($default->getName()); |
||
33 | |||
34 | $this->setAutoExit(false); |
||
35 | $this->setCatchExceptions(false); |
||
36 | } |
||
37 | |||
38 | public function run(InputInterface $input = null, OutputInterface $output = null) |
||
39 | { |
||
40 | return parent::run($input, $output); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Run an Silverstripe console command by name. |
||
45 | * |
||
46 | * @param string $command |
||
47 | * @param array $parameters |
||
48 | * |
||
49 | * @return int |
||
50 | */ |
||
51 | public function call($command, array $parameters = []) |
||
52 | { |
||
53 | $parameters = array_merge((array) $command, $parameters); |
||
54 | |||
55 | $this->lastOutput = new BufferedOutput(); |
||
56 | |||
57 | $this->setCatchExceptions(false); |
||
58 | |||
59 | $result = $this->run(new ArrayInput($parameters), $this->lastOutput); |
||
60 | |||
61 | $this->setCatchExceptions(true); |
||
62 | |||
63 | return $result; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Get the output for the last run command. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | public function output() |
||
75 | |||
76 | /** |
||
77 | * Get the default input definitions for the applications. |
||
78 | * |
||
79 | * This is used to add the --env option to every available command. |
||
80 | * |
||
81 | * @return \Symfony\Component\Console\Input\InputDefinition |
||
82 | */ |
||
83 | protected function getDefaultInputDefinition() |
||
91 | |||
92 | /** |
||
93 | * Get the global environment option for the definition. |
||
94 | * |
||
95 | * @return \Symfony\Component\Console\Input\InputOption |
||
96 | */ |
||
97 | protected function getEnvironmentOption() |
||
103 | |||
104 | /** |
||
105 | * Load all available commands into the console application. |
||
106 | */ |
||
107 | protected function loadCommands() |
||
117 | |||
118 | /** |
||
119 | * When developing and renaming or removing a Command, the manifest is not always updated. |
||
120 | * |
||
121 | * We don't want file_not_found or class_does_not_exists error for commands, |
||
122 | * because that prevente running commands like cache:clear etc. |
||
123 | * |
||
124 | * @param string $class |
||
125 | * @param string $path |
||
126 | */ |
||
127 | protected function addCommandOrSilentlyFail($class, $path) |
||
136 | } |
||
137 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.