-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathps_accounts.php
103 lines (89 loc) · 2.43 KB
/
ps_accounts.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
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class Ps_accounts extends Module
{
/**
* @var string
*/
const VERSION = '0.0.0';
/**
* @var \PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer
*/
private $serviceContainer;
public function __construct()
{
$this->name = 'ps_accounts';
$this->version = '0.0.0';
$this->author = 'CloudSync team';
$this->need_instance = 0;
$this->ps_versions_compliancy = [
'min' => '1.6.1.11',
'max' => '99.99.99',
];
$this->bootstrap = false;
parent::__construct();
$this->displayName = $this->l('PS Accounts Mock');
$this->description = $this->l('Mocking');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
require_once __DIR__ . '/vendor/autoload.php';
$this->serviceContainer = new \PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer(
(string) $this->name,
$this->getLocalPath()
);
}
/**
* @return bool
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
* @throws Exception
*/
public function install()
{
$db = \Db::getInstance();
$dbInstallFile = "{$this->getLocalPath()}/sql/install.sql";
if (!file_exists($dbInstallFile)) {
return false;
}
$sql = \Tools::file_get_contents($dbInstallFile);
if (empty($sql) || !is_string($sql)) {
return false;
}
$sql = str_replace(['PREFIX_', 'ENGINE_TYPE'], [_DB_PREFIX_, _MYSQL_ENGINE_], $sql);
$sql = preg_split("/;\s*[\r\n]+/", trim($sql));
if (!empty($sql)) {
foreach ($sql as $query) {
if (!$db->execute($query)) {
return false;
}
}
}
return parent::install();
}
/**
* @return bool
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
public function uninstall()
{
if (parent::uninstall() == false) {
return false;
}
return true;
}
/**
* @param string $serviceName
*
* @return mixed
*
* @throws Exception
*/
public function getService($serviceName)
{
return $this->serviceContainer->getService($serviceName);
}
}