Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ChangeAnchorAction.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
ChangeAnchorAction
extends
BaseAction
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
}
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\ChangeAnchorAction
Definition
ChangeAnchorAction.php:10
Bitrix\Landing\History\Action\ChangeAnchorAction\getJsCommand
getJsCommand(bool $undo=true)
Definition
ChangeAnchorAction.php:45
Bitrix\Landing\History\Action\ChangeAnchorAction\compareParams
static compareParams(array $oldParams, array $newParams)
Definition
ChangeAnchorAction.php:68
Bitrix\Landing\History\Action\ChangeAnchorAction\enrichParams
static enrichParams(array $params)
Definition
ChangeAnchorAction.php:34
Bitrix\Landing\History\Action\ChangeAnchorAction\execute
execute(bool $undo=true)
Definition
ChangeAnchorAction.php:14
Bitrix\Landing\History\Action\ChangeAnchorAction\JS_COMMAND
const JS_COMMAND
Definition
ChangeAnchorAction.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
ChangeAnchorAction.php
Создано системой
1.10.0