Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
UpdateContentAction.php
1
<?php
2
3
namespace
Bitrix\Landing\History\Action
;
4
5
use
Bitrix\Landing\Block
;
6
7
class
UpdateContentAction
extends
BaseAction
8
{
9
protected
const
JS_COMMAND
=
'updateContent'
;
10
11
public
function
execute
(
bool
$undo =
true
): bool
12
{
13
$block =
new
Block
((
int
)$this->params[
'block'
]);
14
if
($block->exist())
15
{
16
$content = $undo ? $this->params[
'contentBefore'
] : $this->params[
'contentAfter'
];
17
$block->saveContent($content, $this->params[
'designed'
]);
18
19
return
$block->save();
20
}
21
22
return
false
;
23
}
24
25
public
static
function
enrichParams
(array
$params
): array
26
{
27
return
[
28
'block'
=>
$params
[
'block'
],
29
'lid'
=>
$params
[
'contentAfter'
],
30
'contentAfter'
=>
$params
[
'contentAfter'
] ?:
''
,
31
'contentBefore'
=>
$params
[
'contentBefore'
] ?:
''
,
32
'designed'
=> (bool)
$params
[
'designed'
],
33
];
34
}
35
36
public
function
isNeedPush
(): bool
37
{
38
return
39
parent::isNeedPush()
40
&& $this->params[
'contentBefore'
] !== $this->params[
'contentAfter'
];
41
}
42
47
public
function
getJsCommand
(
bool
$undo =
true
): array
48
{
49
$params
= parent::getJsCommand($undo);
50
51
$params
[
'params'
][
'content'
] =
52
$undo
53
?
$params
[
'params'
][
'contentBefore'
]
54
:
$params
[
'params'
][
'contentAfter'
]
55
;
56
57
unset(
58
$params
[
'params'
][
'contentAfter'
],
59
$params
[
'params'
][
'contentBefore'
],
60
$params
[
'params'
][
'designed'
],
61
);
62
63
return
$params
;
64
}
65
}
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\UpdateContentAction
Definition
UpdateContentAction.php:8
Bitrix\Landing\History\Action\UpdateContentAction\getJsCommand
getJsCommand(bool $undo=true)
Definition
UpdateContentAction.php:47
Bitrix\Landing\History\Action\UpdateContentAction\isNeedPush
isNeedPush()
Definition
UpdateContentAction.php:36
Bitrix\Landing\History\Action\UpdateContentAction\enrichParams
static enrichParams(array $params)
Definition
UpdateContentAction.php:25
Bitrix\Landing\History\Action\UpdateContentAction\execute
execute(bool $undo=true)
Definition
UpdateContentAction.php:11
Bitrix\Landing\History\Action\UpdateContentAction\JS_COMMAND
const JS_COMMAND
Definition
UpdateContentAction.php:9
Bitrix\Landing\Block
Definition
cache.php:2
Bitrix\Landing\History\Action
Definition
AddBlockAction.php:3
modules
landing
lib
History
Action
UpdateContentAction.php
Создано системой
1.10.0