| @@ 8-62 (lines=55) @@ | ||
| 5 | use Arrilot\BitrixMigrations\Exceptions\StopHandlerException; |
|
| 6 | use CGroup; |
|
| 7 | ||
| 8 | class OnBeforeGroupDelete extends BaseHandler implements HandlerInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Bitrix group id. |
|
| 12 | * |
|
| 13 | * @var int |
|
| 14 | */ |
|
| 15 | protected $id; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * Constructor. |
|
| 19 | * |
|
| 20 | * @param array $params |
|
| 21 | * |
|
| 22 | * @throws StopHandlerException |
|
| 23 | */ |
|
| 24 | public function __construct($params) |
|
| 25 | { |
|
| 26 | $this->id = $params[0]; |
|
| 27 | ||
| 28 | $this->fields = CGroup::GetByID($this->id)->fetch(); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Get migration name. |
|
| 33 | * |
|
| 34 | * @return string |
|
| 35 | */ |
|
| 36 | public function getName() |
|
| 37 | { |
|
| 38 | return "auto_delete_group_{$this->fields['STRING_ID']}"; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Get template name. |
|
| 43 | * |
|
| 44 | * @return string |
|
| 45 | */ |
|
| 46 | public function getTemplate() |
|
| 47 | { |
|
| 48 | return 'auto_delete_group'; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Get array of placeholders to replace. |
|
| 53 | * |
|
| 54 | * @return array |
|
| 55 | */ |
|
| 56 | public function getReplace() |
|
| 57 | { |
|
| 58 | return [ |
|
| 59 | 'id' => $this->id, |
|
| 60 | ]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| @@ 8-60 (lines=53) @@ | ||
| 5 | use Arrilot\BitrixMigrations\Exceptions\SkipHandlerException; |
|
| 6 | use Bitrix\Main\Entity\Event; |
|
| 7 | ||
| 8 | class OnBeforeHLBlockAdd extends BaseHandler implements HandlerInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Event |
|
| 12 | */ |
|
| 13 | protected $event; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Constructor. |
|
| 17 | * |
|
| 18 | * @param array $params |
|
| 19 | * |
|
| 20 | * @throws SkipHandlerException |
|
| 21 | */ |
|
| 22 | public function __construct($params) |
|
| 23 | { |
|
| 24 | $this->event = $params[0]; |
|
| 25 | ||
| 26 | $this->fields = $this->event->getParameter('fields'); |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Get migration name. |
|
| 31 | * |
|
| 32 | * @return string |
|
| 33 | */ |
|
| 34 | public function getName() |
|
| 35 | { |
|
| 36 | return 'auto_add_hlblock_'.$this->fields['TABLE_NAME']; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Get template name. |
|
| 41 | * |
|
| 42 | * @return string |
|
| 43 | */ |
|
| 44 | public function getTemplate() |
|
| 45 | { |
|
| 46 | return 'auto_add_hlblock'; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Get array of placeholders to replace. |
|
| 51 | * |
|
| 52 | * @return array |
|
| 53 | */ |
|
| 54 | public function getReplace() |
|
| 55 | { |
|
| 56 | return [ |
|
| 57 | 'fields' => var_export($this->fields, true), |
|
| 58 | ]; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||