1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\System\Setup\SubCommand; |
4
|
|
|
|
5
|
|
|
use N98\Magento\Command\SubCommand\AbstractSubCommand; |
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
7
|
|
|
|
8
|
|
|
class DataUpdate extends AbstractSubCommand |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @return bool |
12
|
|
|
*/ |
13
|
|
|
public function execute() |
14
|
|
|
{ |
15
|
|
|
$moduleNames = $this->config->getArray('moduleNames'); |
16
|
|
|
$setupFactory = $this->getCommand() |
17
|
|
|
->getApplication() |
18
|
|
|
->getObjectManager() |
19
|
|
|
->get('Magento\Framework\Module\Updater\SetupFactory'); |
20
|
|
|
|
21
|
|
|
$progress = $this->getCommand()->getHelper('progress'); |
22
|
|
|
|
23
|
|
|
$resourceResolver = $this->getCommand() |
24
|
|
|
->getApplication() |
25
|
|
|
->getObjectManager() |
26
|
|
|
->get('Magento\Framework\Module\ResourceInterface'); |
27
|
|
|
/* @var $resourceResolver \Magento\Framework\Module\ResourceInterface */ |
28
|
|
|
|
29
|
|
|
$dbVersionInfo = $this->getCommand() |
30
|
|
|
->getApplication() |
31
|
|
|
->getObjectManager() |
32
|
|
|
->get('Magento\Framework\Module\DbVersionInfo'); |
33
|
|
|
/* @var $dbVersionInfo \Magento\Framework\Module\DbVersionInfo */ |
34
|
|
|
|
35
|
|
|
$progress->start($this->output, count($moduleNames)); |
36
|
|
|
foreach ($moduleNames as $moduleName) { |
37
|
|
|
if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { |
38
|
|
|
$this->output->writeln("\n" . '<debug>' . $moduleName . '</debug>'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
foreach ($resourceResolver->getResourceList($moduleName) as $resourceName) { |
42
|
|
|
if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { |
43
|
|
|
$this->output->writeln("\n" . '<debug>' . $moduleName . '</debug>'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (!$dbVersionInfo->isDataUpToDate($moduleName, $resourceName)) { |
47
|
|
|
if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { |
48
|
|
|
$this->output->writeln("\n" . '<debug>Run ' . $resourceName . '</debug>'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$setupFactory->create($resourceName, $moduleName)->applyDataUpdates(); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
$progress->advance(); |
55
|
|
|
} |
56
|
|
|
$progress->finish(); |
57
|
|
|
|
58
|
|
|
return true; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|