Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
installer.php
1
<?php
8
namespace
Bitrix\Sender\Preset\Installation
;
9
10
use
Bitrix\Main\Config\Option
;
11
use
Bitrix\Main\Localization\Loc
;
12
13
Loc::loadMessages
(__FILE__);
14
19
class
Installer
20
{
21
protected
$errors
= array();
22
protected
static
$version
= 2;
23
protected
static
$versionOptionName
=
'sender_preset_version'
;
24
30
public
static
function
checkVersion
()
31
{
32
return
self::getVersion
() >
self::getInstalledVersion
();
33
}
34
40
public
static
function
getInstallable
()
41
{
42
return
Factory::getInstallable
();
43
}
44
49
public
static
function
installNewest
()
50
{
51
if
(!self::checkVersion())
52
{
53
return
false
;
54
}
55
56
$instance =
new
self
;
57
return
$instance->install();
58
}
59
64
public
function
install
()
65
{
66
if
(!self::checkVersion())
67
{
68
return
true
;
69
}
70
71
foreach
($this->
getInstallable
() as $installable)
72
{
73
if
($installable->isInstalled())
74
{
75
continue
;
76
}
77
78
$installable->install();
79
}
80
81
if
(!$this->
hasErrors
())
82
{
83
self::updateInstalledVersion
();
84
}
85
86
return
$this->
hasErrors
();
87
}
88
94
public
function
uninstall
(
iInstallable
$installable =
null
)
95
{
96
if
($installable)
97
{
98
$installable->uninstall();
99
}
100
else
101
{
102
foreach
($this->
getInstallable
() as $installable)
103
{
104
if
(!$installable->isInstalled())
105
{
106
continue
;
107
}
108
109
$installable->uninstall();
110
}
111
112
self::updateInstalledVersion
(0);
113
}
114
}
115
121
public
static
function
updateInstalledVersion
(
$version
=
null
)
122
{
123
if
(
$version
===
null
)
124
{
125
$version
=
self::getVersion
();
126
}
127
128
Option::set(
'sender'
, self::$versionOptionName,
$version
);
129
}
130
131
protected
static
function
getVersion
()
132
{
133
return
self::$version
;
134
}
135
136
protected
static
function
getInstalledVersion
()
137
{
138
return
(
int
) Option::get(
'sender'
, self::$versionOptionName, 0);
139
}
140
146
public
function
getErrors
()
147
{
148
return
$this->errors
;
149
}
150
156
public
function
hasErrors
()
157
{
158
return
count($this->errors) > 0;
159
}
160
}
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Sender\Preset\Installation\Factory\getInstallable
static getInstallable()
Definition
factory.php:25
Bitrix\Sender\Preset\Installation\Installer
Definition
installer.php:20
Bitrix\Sender\Preset\Installation\Installer\getVersion
static getVersion()
Definition
installer.php:131
Bitrix\Sender\Preset\Installation\Installer\$version
static $version
Definition
installer.php:22
Bitrix\Sender\Preset\Installation\Installer\installNewest
static installNewest()
Definition
installer.php:49
Bitrix\Sender\Preset\Installation\Installer\updateInstalledVersion
static updateInstalledVersion($version=null)
Definition
installer.php:121
Bitrix\Sender\Preset\Installation\Installer\checkVersion
static checkVersion()
Definition
installer.php:30
Bitrix\Sender\Preset\Installation\Installer\getErrors
getErrors()
Definition
installer.php:146
Bitrix\Sender\Preset\Installation\Installer\$versionOptionName
static $versionOptionName
Definition
installer.php:23
Bitrix\Sender\Preset\Installation\Installer\getInstallable
static getInstallable()
Definition
installer.php:40
Bitrix\Sender\Preset\Installation\Installer\install
install()
Definition
installer.php:64
Bitrix\Sender\Preset\Installation\Installer\hasErrors
hasErrors()
Definition
installer.php:156
Bitrix\Sender\Preset\Installation\Installer\$errors
$errors
Definition
installer.php:21
Bitrix\Sender\Preset\Installation\Installer\uninstall
uninstall(iInstallable $installable=null)
Definition
installer.php:94
Bitrix\Sender\Preset\Installation\Installer\getInstalledVersion
static getInstalledVersion()
Definition
installer.php:136
Bitrix\Sender\Preset\Installation\iInstallable
Definition
iinstallable.php:16
Bitrix\Sender\Preset\Installation
Definition
factory.php:9
modules
sender
lib
preset
installation
installer.php
Создано системой
1.10.0