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