Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ChangeAnchorAction.php
1<?php
2
4
8
10{
11 // now it is not used as separate js command, just as multy
12 protected const JS_COMMAND = 'changeAnchor';
13
14 public function execute(bool $undo = true): bool
15 {
16 $value = $undo ? $this->params['valueBefore'] : $this->params['valueAfter'];
17
18 if ($this->params['block'])
19 {
20 if ($value === '')
21 {
22 return true;
23 }
24
25 $block = new Block((int)$this->params['block']);
26 $block->setAnchor($value);
27
28 return $block->save();
29 }
30
31 return false;
32 }
33
34 public static function enrichParams(array $params): array
35 {
36 $params['block'] = $params['block']->getId();
37
38 return $params;
39 }
40
45 public function getJsCommand(bool $undo = true): array
46 {
47 $params = parent::getJsCommand($undo);
48
49 $params['params']['value'] =
50 $undo
51 ? $params['params']['valueBefore']
52 : $params['params']['valueAfter'];
53
54 unset(
55 $params['params']['valueAfter'],
56 $params['params']['valueBefore'],
57 );
58
59 return $params;
60 }
61
68 public static function compareParams(array $oldParams, array $newParams): bool
69 {
70 unset($oldParams['valueBefore'], $newParams['valueBefore']);
71
72 return $oldParams === $newParams;
73 }
74}
static compareParams(array $oldParams, array $newParams)