Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
UpdateDynamicAction.php
1
<?php
2
3
namespace
Bitrix\Landing\History\Action
;
4
5
use
Bitrix\Landing\Block
;
6
use
Bitrix\Landing\Node
;
7
use
Bitrix\Main\Web\Json
;
8
9
class
UpdateDynamicAction
extends
BaseAction
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
}
Bitrix\Landing\Block
Definition
block.php:21
Bitrix\Landing\History\Action\BaseAction
Definition
BaseAction.php:5
Bitrix\Landing\History\Action\BaseAction\$params
array $params
Definition
BaseAction.php:7
Bitrix\Landing\History\Action\UpdateDynamicAction
Definition
UpdateDynamicAction.php:10
Bitrix\Landing\History\Action\UpdateDynamicAction\getJsCommand
getJsCommand(bool $undo=true)
Definition
UpdateDynamicAction.php:40
Bitrix\Landing\History\Action\UpdateDynamicAction\enrichParams
static enrichParams(array $params)
Definition
UpdateDynamicAction.php:29
Bitrix\Landing\History\Action\UpdateDynamicAction\execute
execute(bool $undo=true)
Definition
UpdateDynamicAction.php:14
Bitrix\Landing\History\Action\UpdateDynamicAction\JS_COMMAND
const JS_COMMAND
Definition
UpdateDynamicAction.php:12
Bitrix\Main\Web\Json
Definition
json.php:11
Bitrix\Landing\Block
Definition
cache.php:2
Bitrix\Landing\History\Action
Definition
AddBlockAction.php:3
Bitrix\Landing\Node
Definition
component.php:2
modules
landing
lib
History
Action
UpdateDynamicAction.php
Создано системой
1.10.0