|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsConsole\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
10
|
|
|
use Xoops\Core\XoopsTpl; |
|
11
|
|
|
|
|
12
|
|
|
class ActivateModuleCommand extends Command |
|
13
|
|
|
{ |
|
14
|
|
|
protected function configure() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->setName("activate-module") |
|
17
|
|
|
->setDescription("Activate an installed module") |
|
18
|
|
|
->setDefinition(array( |
|
19
|
|
|
new InputArgument('module', InputArgument::REQUIRED, 'Module directory name'), |
|
20
|
|
|
))->setHelp(<<<EOT |
|
21
|
|
|
The <info>activate-module</info> command activates a currently installed module. |
|
22
|
|
|
EOT |
|
23
|
|
|
); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
27
|
|
|
{ |
|
28
|
|
|
$module = $input->getArgument('module'); |
|
29
|
|
|
$output->writeln(sprintf('Activating %s', $module)); |
|
|
|
|
|
|
30
|
|
|
$xoops = \Xoops::getInstance(); |
|
31
|
|
|
$moduleHandler = $xoops->getHandlerModule(); |
|
32
|
|
|
$moduleObject = $moduleHandler->getByDirname($module); |
|
|
|
|
|
|
33
|
|
|
if (false === $moduleObject) { |
|
34
|
|
|
$output->writeln(sprintf('<error>%s is not an installed module!</error>', $module)); |
|
35
|
|
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
$moduleObject->setVar('isactive', true); |
|
38
|
|
|
$moduleHandler->insert($moduleObject, true); |
|
39
|
|
|
|
|
40
|
|
|
$blockHandler = $xoops->getHandlerBlock(); |
|
41
|
|
|
$blocks = $blockHandler->getByModule($moduleObject->getVar('mid')); |
|
42
|
|
|
foreach ($blocks as $block) { |
|
43
|
|
|
/* @var $block \Xoops\Core\Kernel\Handlers\XoopsBlock */ |
|
44
|
|
|
$block->setVar('isactive', true); |
|
45
|
|
|
$blockHandler->insert($block); |
|
46
|
|
|
} |
|
47
|
|
|
$output->writeln(sprintf('<info>Set %s module active</info>', $module)); |
|
48
|
|
|
$xoops->cache()->delete('system'); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|