1 | <?php |
||
13 | class Manager |
||
14 | { |
||
15 | /** |
||
16 | * A flag that autocreation was turned on. |
||
17 | * |
||
18 | * @var bool |
||
19 | */ |
||
20 | protected static $isTurnedOn = false; |
||
21 | |||
22 | /** |
||
23 | * @var Migrator |
||
24 | */ |
||
25 | protected static $migrator; |
||
26 | |||
27 | /** |
||
28 | * Handlers that are used by autocreation. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected static $handlers = [ |
||
33 | 'iblock' => [ |
||
34 | 'OnBeforeIBlockAdd' => 'OnBeforeIBlockAdd', |
||
35 | 'OnBeforeIBlockUpdate' => 'OnBeforeIBlockUpdate', |
||
36 | 'OnBeforeIBlockDelete' => 'OnBeforeIBlockDelete', |
||
37 | 'OnBeforeIBlockPropertyAdd' => 'OnBeforeIBlockPropertyAdd', |
||
38 | 'OnBeforeIBlockPropertyUpdate' => 'OnBeforeIBlockPropertyUpdate', |
||
39 | 'OnBeforeIBlockPropertyDelete' => 'OnBeforeIBlockPropertyDelete', |
||
40 | ], |
||
41 | 'main' => [ |
||
42 | 'OnBeforeUserTypeAdd' => 'OnBeforeUserTypeAdd', |
||
43 | 'OnBeforeUserTypeDelete' => 'OnBeforeUserTypeDelete', |
||
44 | 'OnBeforeGroupAdd' => 'OnBeforeGroupAdd', |
||
45 | 'OnBeforeGroupUpdate' => 'OnBeforeGroupUpdate', |
||
46 | 'OnBeforeGroupDelete' => 'OnBeforeGroupDelete', |
||
47 | ], |
||
48 | 'highloadblock' => [ |
||
49 | '\\Bitrix\\Highloadblock\\Highloadblock::OnBeforeAdd' => 'OnBeforeHLBlockAdd', |
||
50 | '\\Bitrix\\Highloadblock\\Highloadblock::OnBeforeUpdate' => 'OnBeforeHLBlockUpdate', |
||
51 | '\\Bitrix\\Highloadblock\\Highloadblock::OnBeforeDelete' => 'OnBeforeHLBlockDelete', |
||
52 | ], |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * Initialize autocreation. |
||
57 | * |
||
58 | * @param string $dir |
||
59 | * @param string|null $table |
||
60 | */ |
||
61 | public static function init($dir, $table = null) |
||
77 | |||
78 | /** |
||
79 | * Determine if autocreation is turned on. |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | public static function isTurnedOn() |
||
87 | |||
88 | /** |
||
89 | * Turn on autocreation. |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | public static function turnOn() |
||
97 | |||
98 | /** |
||
99 | * Turn off autocreation. |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | public static function turnOff() |
||
107 | |||
108 | /** |
||
109 | * Instantiate handler. |
||
110 | * |
||
111 | * @param string $handler |
||
112 | * @param array $parameters |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | protected static function instantiateHandler($handler, $parameters) |
||
122 | |||
123 | /** |
||
124 | * Create migration and apply it. |
||
125 | * |
||
126 | * @param HandlerInterface $handler |
||
127 | */ |
||
128 | protected static function createMigration(HandlerInterface $handler) |
||
142 | |||
143 | /** |
||
144 | * Add event handlers. |
||
145 | */ |
||
146 | protected static function addEventHandlers() |
||
163 | |||
164 | /** |
||
165 | * Magic static call to a handler. |
||
166 | * |
||
167 | * @param string $method |
||
168 | * @param array $parameters |
||
169 | * |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public static function __callStatic($method, $parameters) |
||
195 | } |
||
196 |