1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
4
|
|
|
* file that was distributed with this source code. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Notamedia\ConsoleJedi\Module\Command; |
8
|
|
|
|
9
|
|
|
use Notamedia\ConsoleJedi\Application\Command\BitrixCommand; |
10
|
|
|
use Notamedia\ConsoleJedi\Module\Module; |
11
|
|
|
use Symfony\Component\Console\Command\Command; |
12
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
14
|
|
|
use Symfony\Component\Console\Input\InputOption; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Module command base class. |
19
|
|
|
* |
20
|
|
|
* @author Marat Shamshutdinov <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
abstract class ModuleCommand extends BitrixCommand |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
protected function configure() |
28
|
|
|
{ |
29
|
|
|
parent::configure(); |
30
|
|
|
|
31
|
|
|
$this->addArgument('module', InputArgument::REQUIRED, 'Module name (e.g. `vendor.module`)') |
32
|
|
|
->addOption('confirm-thirdparty', 'ct', InputOption::VALUE_NONE, 'Suppress third-party modules warning'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritdoc |
37
|
|
|
*/ |
38
|
|
|
protected function interact(InputInterface $input, OutputInterface $output) |
39
|
|
|
{ |
40
|
|
|
parent::interact($input, $output); |
41
|
|
|
|
42
|
|
|
$module = new Module($input->getArgument('module')); |
43
|
|
|
|
44
|
|
|
if (in_array($this->getName(), ['module:register', 'module:unregister']) |
45
|
|
|
&& $module->isThirdParty() && !$input->getOption('confirm-thirdparty') |
46
|
|
|
) { |
47
|
|
|
$output->writeln($module->isThirdParty() . ' is not a kernel module. Correct operation cannot be guaranteed for third-party modules!'); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Gets console commands from this package. |
53
|
|
|
* |
54
|
|
|
* @return Command[] |
55
|
|
|
*/ |
56
|
|
|
public static function getCommands() |
57
|
|
|
{ |
58
|
|
|
return [ |
59
|
|
|
new LoadCommand(), |
60
|
|
|
new RegisterCommand(), |
61
|
|
|
new RemoveCommand(), |
62
|
|
|
new UnregisterCommand(), |
63
|
|
|
new UpdateCommand(), |
64
|
|
|
]; |
65
|
|
|
} |
66
|
|
|
} |