Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ChangeNodeNameAction.php
1<?php
2
4
8
10{
11 protected const JS_COMMAND = 'cnangeNodeName';
12
13 public function execute(bool $undo = true): bool
14 {
15 $block = new Block((int)$this->params['block']);
16 $value = $undo ? $this->params['valueBefore'] : $this->params['valueAfter'];
17 if ($value)
18 {
19 if ($block->changeNodeName($value))
20 {
21 return $block->save();
22 }
23 }
24
25 return false;
26 }
27
28 public static function enrichParams(array $params): array
29 {
33 $block = $params['block'];
34
35 return [
36 'block' => $block->getId(),
37 'lid' => $block->getLandingId(),
38 'valueBefore' => $params['valueBefore'] ?? [],
39 'valueAfter' => $params['valueAfter'] ?? [],
40 ];
41 }
42
47 public function getJsCommand(bool $undo = true): array
48 {
49 $params = parent::getJsCommand($undo);
50 $value = $undo ? $params['params']['valueBefore'] : $params['params']['valueAfter'];
51
52 foreach ($value as $sel => $valueItem)
53 {
54 foreach ($valueItem as $pos => $tag)
55 {
56 $selector = $sel . '@' . $pos;
57 $params['params']['selector'] = $selector;
58 $params['params']['value'] = $tag;
59 break;
60 }
61 break;
62 }
63
64 unset(
65 $params['params']['valueAfter'],
66 $params['params']['valueBefore'],
67 );
68
69 return $params;
70 }
71}