1 | <?php |
||
27 | abstract class AbstractMagentoCommand extends Command |
||
28 | { |
||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | const MAGENTO_MAJOR_VERSION_2 = 2; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | const CONFIG_KEY_COMMANDS = 'commands'; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $_magentoRootFolder = null; |
||
43 | |||
44 | /** |
||
45 | * @var int |
||
46 | */ |
||
47 | protected $_magentoMajorVersion = self::MAGENTO_MAJOR_VERSION_2; |
||
48 | |||
49 | /** |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $_magentoEnterprise = false; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $_deprecatedAlias = array(); |
||
58 | |||
59 | /** |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $_websiteCodeMap = array(); |
||
63 | |||
64 | /** |
||
65 | * @var ObjectManager |
||
66 | */ |
||
67 | protected $_objectManager = null; |
||
68 | |||
69 | /** |
||
70 | * Initializes the command just after the input has been validated. |
||
71 | * |
||
72 | * This is mainly useful when a lot of commands extends one main command |
||
73 | * where some things need to be initialized based on the input arguments and options. |
||
74 | * |
||
75 | * @param InputInterface $input An InputInterface instance |
||
76 | * @param OutputInterface $output An OutputInterface instance |
||
77 | */ |
||
78 | protected function initialize(InputInterface $input, OutputInterface $output) |
||
82 | |||
83 | /** |
||
84 | * @return ObjectManagerInterface |
||
85 | */ |
||
86 | protected function getObjectManager() |
||
90 | |||
91 | /** |
||
92 | * @param string|null $commandClass |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function getCommandConfig($commandClass = null) |
||
107 | |||
108 | /** |
||
109 | * @param OutputInterface $output |
||
110 | * @param string $text |
||
111 | * @param string $style |
||
112 | */ |
||
113 | protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white') |
||
124 | |||
125 | /** |
||
126 | * Bootstrap magento shop |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | protected function initMagento() |
||
139 | |||
140 | /** |
||
141 | * Search for magento root folder |
||
142 | * |
||
143 | * @param OutputInterface $output |
||
144 | * @param bool $silent print debug messages |
||
145 | * @throws \RuntimeException |
||
146 | */ |
||
147 | public function detectMagento(OutputInterface $output, $silent = true) |
||
168 | |||
169 | /** |
||
170 | * @param InputInterface $input |
||
171 | * @param OutputInterface $output |
||
172 | * @return \Composer\Downloader\DownloadManager |
||
173 | */ |
||
174 | public function getComposerDownloadManager($input, $output) |
||
178 | |||
179 | /** |
||
180 | * @param array $config |
||
181 | * @return PackageInterface |
||
182 | */ |
||
183 | public function createComposerPackageByConfig(array $config) |
||
189 | |||
190 | /** |
||
191 | * @param InputInterface $input |
||
192 | * @param OutputInterface $output |
||
193 | * @param array|PackageInterface $config |
||
194 | * @param string $targetFolder |
||
195 | * @param bool $preferSource |
||
196 | * @return \Composer\Package\PackageInterface |
||
197 | */ |
||
198 | public function downloadByComposerConfig( |
||
224 | |||
225 | /** |
||
226 | * brings locally cached repository up to date if it is missing the requested tag |
||
227 | * |
||
228 | * @param PackageInterface $package |
||
229 | * @param string $targetFolder |
||
230 | */ |
||
231 | protected function checkRepository(PackageInterface $package, $targetFolder) |
||
257 | |||
258 | /** |
||
259 | * @param string $type |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | public function isSourceTypeRepository($type) |
||
267 | |||
268 | /** |
||
269 | * obtain composer |
||
270 | * |
||
271 | * @param InputInterface $input |
||
272 | * @param OutputInterface $output |
||
273 | * |
||
274 | * @return \Composer\Composer |
||
275 | */ |
||
276 | public function getComposer(InputInterface $input, OutputInterface $output) |
||
287 | |||
288 | /** |
||
289 | * @param string $alias |
||
290 | * @param string $message |
||
291 | * @return AbstractMagentoCommand |
||
292 | */ |
||
293 | protected function addDeprecatedAlias($alias, $message) |
||
299 | |||
300 | /** |
||
301 | * @param InputInterface $input |
||
302 | * @param OutputInterface $output |
||
303 | */ |
||
304 | protected function checkDeprecatedAliases(InputInterface $input, OutputInterface $output) |
||
313 | |||
314 | /** |
||
315 | * @param string $value |
||
316 | * @return bool |
||
317 | */ |
||
318 | protected function _parseBoolOption($value) |
||
322 | |||
323 | /** |
||
324 | * @param string $value |
||
325 | * @return bool |
||
326 | */ |
||
327 | public function parseBoolOption($value) |
||
331 | |||
332 | /** |
||
333 | * @param string $value |
||
334 | * @return string |
||
335 | */ |
||
336 | public function formatActive($value) |
||
344 | |||
345 | /** |
||
346 | * @param InputInterface $input |
||
347 | * @param OutputInterface $output |
||
348 | * |
||
349 | * @return int |
||
350 | */ |
||
351 | public function run(InputInterface $input, OutputInterface $output) |
||
359 | |||
360 | /** |
||
361 | * @param OutputInterface $output |
||
362 | */ |
||
363 | public function injectObjects(OutputInterface $output) |
||
379 | |||
380 | /** |
||
381 | * @param InputInterface $input |
||
382 | * @param OutputInterface $output |
||
383 | * @param string $baseNamespace If this is set we can use relative class names. |
||
384 | * |
||
385 | * @return SubCommandFactory |
||
386 | */ |
||
387 | protected function createSubCommandFactory( |
||
408 | } |
||
409 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: