Completed
Pull Request — develop (#182)
by Tom
04:37
created

InitZendApp::getMagentoRootFolder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace N98\Magento\Command\System\Setup\SubCommand;
4
5
use N98\Magento\Command\SubCommand\AbstractSubCommand;
6
use N98\Magento\Command\System\Setup\BridgetConsoleLogger;
7
8
class InitZendApp extends AbstractSubCommand
9
{
10
    /**
11
     * @return bool
12
     */
13
    public function execute()
14
    {
15
        $zendApplication = \Zend\Mvc\Application::init(
16
            require $this->getMagentoRootFolder() . '/setup/config/application.config.php'
17
        );
18
19
        $serviceManager = $zendApplication->getServiceManager();
20
        $this->config->setObject('zendServiceManager', $serviceManager);
21
22
        $setupFactory = $serviceManager->get('Magento\Setup\Module\SetupFactory');
23
        /* @var $setupFactory \Magento\Setup\Module\SetupFactory */
24
        $this->config->setObject('setupFactory', $setupFactory);
25
26
        $moduleList = $this->getCommand()
27
            ->getApplication()
28
            ->getObjectManager()->get('Magento\Framework\Module\ModuleListInterface');
29
30
        /* @var $modules \Magento\Framework\Module\ModuleListInterface */
31
        $this->config->setArray('moduleNames', $moduleList->getNames());
32
33
        $logger = new BridgetConsoleLogger($this->output);
34
        /* @var $logger \Magento\Setup\Model\LoggerInterface */
35
        $this->config->setObject('logger', $logger);
36
37
        return true;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    private function getMagentoRootFolder()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
44
    {
45
        return $this->getCommand()->getApplication()->getMagentoRootFolder();
46
    }
47
}
48