Test Failed
Push — CI ( 785a66...02428e )
by Adam
54:23
created

InstallCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
/**
3
 * Created by Adam Jakab.
4
 * Date: 08/03/16
5
 * Time: 9.03
6
 */
7
8
namespace SuiteCrm\Install;
9
10
use SuiteCrm\Command\Command;
11
use SuiteCrm\Command\CommandInterface;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Symfony\Component\Filesystem\Filesystem;
16
17
class InstallCommand extends Command implements CommandInterface
18
{
19
    const COMMAND_NAME = 'app:install';
20
    const COMMAND_DESCRIPTION = 'Install the SuiteCrm application';
21
22
    /** @var bool */
23
    private $logToConsole = TRUE;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
25
    public function __construct() {
26
        $this->enableConsoleLogging($this->logToConsole);
27
        parent::__construct(NULL);
28
    }
29
30
    /**
31
     * Configure command
32
     */
33
    protected function configure() {
34
        $this->setName(static::COMMAND_NAME);
35
        $this->setDescription(static::COMMAND_DESCRIPTION);
36
    }
37
38
    /**
39
     * @param InputInterface $input
40
     * @param OutputInterface $output
41
     * @return bool
42
     */
43
    protected function execute(InputInterface $input, OutputInterface $output) {
44
        parent::_execute($input, $output);
45
        $this->log("Starting command " . static::COMMAND_NAME . "...");
46
        $this->doPhpVersionCheck();
47
        $this->setupSugarGlobals();
48
        $this->setupSugarLogger();
49
        $this->executeInstallation();
50
51
52
53
        $this->log("Command " . static::COMMAND_NAME . " done.");
54
    }
55
56
57
    /**
58
     *
59
     */
60
    protected function executeInstallation() {
61
        define('sugarEntry', true);
62
        //require_once(PROJECT_ROOT . '/include/SugarLogger/LoggerManager.php');
63
        require_once(PROJECT_ROOT . '/sugar_version.php');
64
        require_once(PROJECT_ROOT . '/suitecrm_version.php');
65
        require_once(PROJECT_ROOT . '/include/utils.php');
66
        require_once(PROJECT_ROOT . '/install/install_utils.php');
67
        require_once(PROJECT_ROOT . '/install/install_defaults.php');
68
        require_once(PROJECT_ROOT . '/include/TimeDate.php');
69
        require_once(PROJECT_ROOT . '/include/Localization/Localization.php');
70
        require_once(PROJECT_ROOT . '/include/SugarTheme/SugarTheme.php');
71
        require_once(PROJECT_ROOT . '/include/utils/LogicHook.php');
72
        require_once(PROJECT_ROOT . '/data/SugarBean.php');
73
        require_once(PROJECT_ROOT . '/include/entryPoint.php');
74
        //
75
        $timedate = \TimeDate::getInstance();
76
        setPhpIniSettings();
77
        $locale = new \Localization();
78
        /** @var  string $suitecrm_version */
79
        $setup_sugar_version = $suitecrm_version;
80
        $install_script = true;
81
        $current_language = 'en_us';
82
83
        try {
84
            SystemChecker::runChecks();
85
        } catch(\Exception $e) {
86
            $this->log("SYSTEM CHECK ERROR! " . $e->getMessage());
87
            die();
88
        }
89
90
91
    }
92
93
94
    /**
95
     *  Set up a custom logger for the installation
96
     */
97
    protected function setupSugarLogger() {
98
        $GLOBALS['log'] = new LoggerManager($this->cmdOutput, 'debug');
99
    }
100
101
    /**
102
     * Setup Globals prior to requiring Sugar application files
103
     */
104
    protected function setupSugarGlobals() {
105
        $GLOBALS['installing'] = true;
106
        define('SUGARCRM_IS_INSTALLING', $GLOBALS['installing']);
107
        $GLOBALS['sql_queries'] = 0;
108
    }
109
110
    /**
111
     * @throws \Exception
112
     */
113
    protected function doPhpVersionCheck() {
114
        if (version_compare(phpversion(),'5.2.0') < 0) {
115
            throw new \Exception('Minimum PHP version required is 5.2.0.  You are using PHP version  '. phpversion());
116
        }
117
    }
118
}