OnBeforeHLBlockDelete::getReplace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Arrilot\BitrixMigrations\Autocreate\Handlers;
4
5
use Arrilot\BitrixMigrations\Exceptions\SkipHandlerException;
6
use Bitrix\Highloadblock\HighloadBlockTable;
7
use Bitrix\Main\Entity\Event;
8
9
class OnBeforeHLBlockDelete extends BaseHandler implements HandlerInterface
10
{
11
    /**
12
     * @var Event
13
     */
14
    protected $event;
15
16
    /**
17
     * HLBlock id.
18
     *
19
     * @var int
20
     */
21
    protected $id;
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param array $params
27
     *
28
     * @throws SkipHandlerException
29
     */
30
    public function __construct($params)
31
    {
32
        $this->event = $params[0];
33
34
        $eventParams = $this->event->getParameters();
35
36
        $this->id = $eventParams['id']['ID'];
37
        $this->fields = HighloadBlockTable::getById($this->id)->fetch();
38
    }
39
40
    /**
41
     * Get migration name.
42
     *
43
     * @return string
44
     */
45
    public function getName()
46
    {
47
        return 'auto_delete_hlblock_'.$this->fields['TABLE_NAME'];
48
    }
49
50
    /**
51
     * Get template name.
52
     *
53
     * @return string
54
     */
55
    public function getTemplate()
56
    {
57
        return 'auto_delete_hlblock';
58
    }
59
60
    /**
61
     * Get array of placeholders to replace.
62
     *
63
     * @return array
64
     */
65
    public function getReplace()
66
    {
67
        return [
68
            'fields' => var_export($this->fields, true),
69
            'id'     => $this->id,
70
        ];
71
    }
72
}
73