forked from nicolasleon/Maintenance
/
Maintenance.php
executable file
·65 lines (54 loc) · 2.08 KB
/
Maintenance.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
<?php
/*************************************************************************************/
/* Maintenance mode plugin for Thelia 2 */
/* */
/* Copyright (c) Omnitic */
/* email : nicolas@omnitic.com */
/* web : http://www.omnitic.com */
/* */
/*************************************************************************************/
namespace Maintenance;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\ConfigQuery;
use Thelia\Module\BaseModule;
class Maintenance extends BaseModule
{
const MESSAGE_DOMAIN = "maintenance";
private $settings = [
'com.omnitic.maintenance_mode' => 0,
'com.omnitic.maintenance_template_name' => 'maintenance',
'com.omnitic.maintenance_message' => 'Nous mettons à jour notre boutique. Revenez nous voir dans quelques minutes.',
'com.omnitic.maintenance_allowed_ips' => '',
];
/*
* Install the default module settings
*
*/
public function postActivation(ConnectionInterface $con = null)
{
foreach ($this->settings as $setting_name => $value) {
$setting = ConfigQuery::read($setting_name);
if (empty($setting)) {
ConfigQuery::write($setting_name, $value, null, 1);
}
}
}
/*
* Delete module data on module destroy
*
*
*/
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
{
foreach ($this->settings as $setting_name => $value) {
$setting = ConfigQuery::create()->findOneByName($setting_name);
if ($setting !== null) {
$setting->delete();
}
}
}
public function getCode()
{
return 'Maintenance';
}
}