-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisys_module_lfischer_commander.class.php
205 lines (177 loc) · 5.47 KB
/
isys_module_lfischer_commander.class.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
use idoit\AddOn\ActivatableInterface;
use idoit\AddOn\ExtensionProviderInterface;
use idoit\AddOn\InstallableInterface;
use idoit\Exception\JsonException;
use idoit\Module\Lfischer_commander\CommanderExtension;
use idoit\Module\Lfischer_commander\Processor;
use idoit\Module\Lfischer_commander\Processor\Activate;
use idoit\Module\Lfischer_commander\Processor\Deactivate;
use idoit\Module\Lfischer_commander\Processor\Install;
use idoit\Module\Lfischer_commander\Processor\Uninstall;
use idoit\Module\Lfischer_commander\Processor\Update;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
/**
* i-doit
*
* Add-on lfischer_commander module class.
*
* @package lfischer_commander
* @copyright Leonard Fischer
* @license
*/
class isys_module_lfischer_commander extends isys_module implements ActivatableInterface, ExtensionProviderInterface, InstallableInterface
{
// Define, if this module shall be displayed in the named menus.
const DISPLAY_IN_MAIN_MENU = false;
const DISPLAY_IN_SYSTEM_MENU = false;
const MAIN_MENU_REWRITE_LINK = false;
/**
* @var bool
*/
protected static $m_licenced = true;
/**
* @return void
*/
public function start()
{
if (!self::is_licenced()) {
global $g_error;
$g_error = $message = $this->language->get('LC__LICENCE__NO_MODULE_LICENCE', [$this->language->get('Commander')]);
isys_notify::error($message, ['sticky' => true]);
return;
}
}
/**
* Initializes the module.
*
* @param isys_module_request $p_req
*/
public function init(isys_module_request $p_req)
{
}
/**
* Returns the module's container extension.
*
* @return ExtensionInterface
*/
public function getContainerExtension()
{
return new CommanderExtension();
}
/**
* Checks if a add-on is installed.
*
* @return int|bool
*/
public static function isInstalled()
{
return isys_module_manager::instance()
->is_installed('lfischer_commander');
}
/**
* Basic installation process for all mandators.
*
* @param isys_component_database $tenantDatabase
* @param isys_component_database $systemDatabase
* @param int $moduleId
* @param string $type
* @param int $tenantId
*
* @return bool
* @throws JsonException
* @throws isys_exception_dao
* @throws isys_exception_database
*/
public static function install($tenantDatabase, $systemDatabase, $moduleId, $type, $tenantId)
{
// Dummy autoloader for the admin-center.
if (!class_exists(Processor::class)) {
include_once __DIR__ . '/src/Processor.php';
}
if ($type === 'install') {
if (!class_exists(Install::class)) {
include_once __DIR__ . '/src/Processor/Install.php';
}
(new Install($tenantDatabase, (int)$tenantId))->process();
}
if (!class_exists(Update::class)) {
include_once __DIR__ . '/src/Processor/Update.php';
}
(new Update($tenantDatabase, (int)$tenantId))->process();
return true;
}
/**
* Uninstall add-on for all mandators.
*
* @param isys_component_database $tenantDatabase
*
* @return boolean
* @throws JsonException
* @throws isys_exception_dao
*/
public static function uninstall($tenantDatabase)
{
// Dummy autoloader for the admin-center.
if (!class_exists(Processor::class)) {
include_once __DIR__ . '/src/Processor.php';
}
if (!class_exists(Uninstall::class)) {
include_once __DIR__ . '/src/Processor/Uninstall.php';
}
(new Uninstall($tenantDatabase))->process();
return true;
}
/**
* Checks if a add-on is active.
*
* @return integer|bool
*/
public static function isActive()
{
return isys_module_manager::instance()
->is_installed('lfischer_commander', true);
}
/**
* Method that is called after clicking "activate" in admin center for specific mandator.
*
* @param isys_component_database $tenantDatabase
*
* @return boolean
* @throws JsonException
* @throws isys_exception_dao
*/
public static function activate($tenantDatabase)
{
// Dummy autoloader for the admin-center.
if (!class_exists(Processor::class)) {
include_once __DIR__ . '/src/Processor.php';
}
if (!class_exists(Activate::class)) {
include_once __DIR__ . '/src/Processor/Activate.php';
}
(new Activate($tenantDatabase))->process();
return true;
}
/**
* Method that is called after clicking "deactivate" in admin center for specific mandator.
*
* @param isys_component_database $tenantDatabase
*
* @return boolean
* @throws isys_exception_dao
* @throws JsonException
*/
public static function deactivate($tenantDatabase)
{
// Dummy autoloader for the admin-center.
if (!class_exists(Processor::class)) {
include_once __DIR__ . '/src/Processor.php';
}
if (!class_exists(Deactivate::class)) {
include_once __DIR__ . '/src/Processor/Deactivate.php';
}
(new Deactivate($tenantDatabase))->process();
return true;
}
}