Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
installer.php
1<?php
9
12
13Loc::loadMessages(__FILE__);
14
20{
21 protected $errors = array();
22 protected static $version = 2;
23 protected static $versionOptionName = 'sender_preset_version';
24
30 public static function checkVersion()
31 {
33 }
34
40 public static function getInstallable()
41 {
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 {
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
113 }
114 }
115
121 public static function updateInstalledVersion($version = null)
122 {
123 if($version === null)
124 {
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}
static loadMessages($file)
Definition loc.php:64
uninstall(iInstallable $installable=null)
Definition installer.php:94