-
Notifications
You must be signed in to change notification settings - Fork 7
/
script.php
138 lines (117 loc) · 2.98 KB
/
script.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* @package quantummanager
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
* @license GNU General Public License version 3 or later; see license.txt
* @link https://www.norrnext.com
*/
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Version;
use Joomla\Component\QuantumManager\Administrator\Helper\QuantummanagerHelper;
defined('_JEXEC') or die;
/**
* Quantummanager script file.
*
* @package A package name
* @since 1.0
*/
class com_quantummanagerInstallerScript
{
/**
* Minimum PHP version required to install the extension.
*
* @var string
*
* @since 0.0.1
*/
protected $minimumPhp = '7.4';
/**
* Minimum Joomla version required to install the extension.
*
* @var string
*
* @since 0.0.1
*/
protected $minimumJoomla = '4.0.0';
/**
* @var string
*/
protected $helpURL = 'https://docs.norrnext.com/quantum-manager/';
/**
* Extensions for php
* @var array
*/
protected $extensions = [
'fileinfo',
'curl',
'mbstring'
];
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, $adapter)
{
$app = Factory::getApplication();
if (!(version_compare(PHP_VERSION, $this->minimumPhp) >= 0))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_COMPATIBLE_PHP', $this->minimumPhp),
'error');
return false;
}
$jversion = new Version();
if (!$jversion->isCompatible($this->minimumJoomla))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_COMPATIBLE_PHP', $this->minimumJoomla),
'error');
return false;
}
//Check extension
$extensionsNotLoaded = [];
foreach ($this->extensions as $extension)
{
if (!extension_loaded($extension))
{
$extensionsNotLoaded[] = $extension;
}
}
if (count($extensionsNotLoaded))
{
$app->enqueueMessage(Text::sprintf('COM_QUANTUMMANAGER_ERROR_EXTENSIONS', implode(',', $extensionsNotLoaded)),
'error');
return false;
}
}
/**
* This method is called after a component is updated.
*
* @param \stdClass $parent - Parent object calling object.
*
* @return void
*/
public function update($parent)
{
//QuantummanagerHelper::setComponentsParams('helpURL', $this->helpURL);
}
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, $adapter)
{
if ($route === 'install')
{
//QuantummanagerHelper::setComponentsParams('helpURL', $this->helpURL);
}
}
}