1 | <?php |
||
18 | class Main |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Config class instance |
||
23 | * @var \gplcart\core\Config $config |
||
24 | */ |
||
25 | protected $config; |
||
26 | |||
27 | /** |
||
28 | * @param Config $config |
||
29 | */ |
||
30 | public function __construct(Config $config) |
||
34 | |||
35 | /** |
||
36 | * Implements hook "route.list" |
||
37 | * @param array $routes |
||
38 | */ |
||
39 | public function hookRouteList(array &$routes) |
||
47 | |||
48 | /** |
||
49 | * Implements hook "install.handlers" |
||
50 | * @param array $handlers |
||
51 | */ |
||
52 | public function hookInstallHandlers(array &$handlers) |
||
56 | |||
57 | /** |
||
58 | * Implements hook "install.before" |
||
59 | * @param array $data |
||
60 | * @param mixed $result |
||
61 | */ |
||
62 | public function hookInstallBefore(array $data, &$result) |
||
66 | |||
67 | /** |
||
68 | * Implements hook "template.render" |
||
69 | * @param array $templates |
||
70 | */ |
||
71 | public function hookTemplateRender(array &$templates) |
||
75 | |||
76 | /** |
||
77 | * Adds installation handlers |
||
78 | * @param array $handlers |
||
79 | */ |
||
80 | protected function setInstallHandlers(array &$handlers) |
||
81 | { |
||
82 | $handlers['base'] = array( |
||
83 | 'module' => 'base', |
||
84 | 'title' => gplcart_text('Base'), |
||
85 | 'steps' => array( |
||
86 | 1 => array('title' => gplcart_text('Configure modules')), |
||
87 | 2 => array('title' => gplcart_text('Create demo')), |
||
88 | 3 => array('title' => gplcart_text('Finish installation')) |
||
89 | ), |
||
90 | 'handlers' => array( |
||
91 | 'install' => array('gplcart\\modules\\base\\handlers\\Install', 'install'), |
||
92 | 'install_1' => array('gplcart\\modules\\base\\handlers\\Install', 'installModules'), |
||
93 | 'install_2' => array('gplcart\\modules\\base\\handlers\\Install', 'installDemo'), |
||
94 | 'install_3' => array('gplcart\\modules\\base\\handlers\\Install', 'installFinish') |
||
95 | ) |
||
96 | ); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Check if all required modules in place |
||
101 | * @param array $data |
||
102 | * @param array $result |
||
103 | */ |
||
104 | protected function checkRequiredModules(array $data, &$result) |
||
105 | { |
||
106 | if ($data['installer'] === 'base' |
||
107 | && empty($data['step']) |
||
108 | && !$this->getModel()->hasAllRequiredModules()) { |
||
109 | |||
110 | $result = array( |
||
111 | 'redirect' => '', |
||
112 | 'severity' => 'warning', |
||
113 | 'message' => gplcart_text('You cannot use this installer because some modules are missed in your distribution') |
||
114 | ); |
||
115 | } |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Replace system templates |
||
120 | * @param array $templates |
||
121 | */ |
||
122 | protected function replaceTemplates(array &$templates) |
||
128 | |||
129 | /** |
||
130 | * Returns the module model |
||
131 | * @return \gplcart\modules\base\models\Install |
||
132 | */ |
||
133 | public function getModel() |
||
139 | |||
140 | } |
||
141 |