Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
UpdateDynamicAction.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 = 'updateDynamic';
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'] && is_array($value))
19 {
20 $block = new Block((int)$this->params['block']);
21 $block->saveDynamicParams($value);
22
23 return $block->save();
24 }
25
26 return false;
27 }
28
29 public static function enrichParams(array $params): array
30 {
31 $params['block'] = $params['block']->getId();
32
33 return $params;
34 }
35
40 public function getJsCommand(bool $undo = true): array
41 {
42 $params = parent::getJsCommand($undo);
43
44 $params['params']['value'] =
45 $undo
46 ? $params['params']['valueBefore']
47 : $params['params']['valueAfter'];
48
49 unset(
50 $params['params']['valueAfter'],
51 $params['params']['valueBefore'],
52 );
53
54 $params['params']['dynamicParams'] = $params['params']['value'];
55 $params['params']['dynamicState'] = [];
56 foreach (array_keys($params['params']['dynamicParams']) as $selector)
57 {
58 $params['params']['dynamicState'][$selector] = true;
59 }
60 if (!$params['params']['dynamicState']['wrapper'])
61 {
62 !$params['params']['dynamicState']['wrapper'] = false;
63 }
64
65 return $params;
66 }
67}