1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
TaskSaveBlocksHistory.php
См. документацию.
1
<?php
2
declare(strict_types=1);
3
4
namespace
Bitrix\Landing\Copilot\Generation\Step;
5
6
use Bitrix\Landing\Copilot\Generation\GenerationException;
7
use Bitrix\Landing\History;
8
use Bitrix\Landing\Rights;
9
10
class
TaskSaveBlocksHistory
extends
TaskStep
11
{
18
public
function
execute
(): bool
19
{
20
parent::execute();
21
22
$contentsBefore = $this->generation->getData(
TaskPresaveBlocksHistory::DATA_KEY
);
23
if
(
24
!is_array($contentsBefore)
25
|| empty($contentsBefore)
26
)
27
{
28
return
true
;
29
}
30
31
Rights::setGlobalOff
();
32
$historyState = History::isActive();
33
History::activate();
34
35
if
($this->saveHistory($contentsBefore))
36
{
37
$this->generation->deleteData(
TaskPresaveBlocksHistory::DATA_KEY
);
38
}
39
40
Rights::setGlobalOn
();
41
if
(!$historyState)
42
{
43
History::deactivate();
44
}
45
46
return
true
;
47
}
48
49
private
function
saveHistory(
array
$contentsBefore): bool
50
{
51
$landing = $this->siteData->getLandingInstance();
52
if
(!$landing)
53
{
54
return
false
;
55
}
56
57
$history =
new
History
($landing->getId(), History::ENTITY_TYPE_LANDING);
58
59
foreach
($contentsBefore as $blockId => $contentBefore)
60
{
61
$block = $landing->getBlockById($blockId);
62
if
(!$block)
63
{
64
continue
;
65
}
66
67
$history->push(
'UPDATE_CONTENT'
, [
68
'block'
=> $blockId,
69
'contentBefore'
=> $contentBefore,
70
'contentAfter'
=> $block->getContent(),
71
]);
72
}
73
74
return
true
;
75
}
76
}
Bitrix\Landing\Copilot\Generation\Step\TaskPresaveBlocksHistory\DATA_KEY
const DATA_KEY
Определения
TaskPresaveBlocksHistory.php:12
Bitrix\Landing\Copilot\Generation\Step\TaskSaveBlocksHistory
Определения
TaskSaveBlocksHistory.php:11
Bitrix\Landing\Copilot\Generation\Step\TaskSaveBlocksHistory\execute
execute()
Определения
TaskSaveBlocksHistory.php:18
Bitrix\Landing\Copilot\Generation\Step\TaskStep
Определения
TaskStep.php:10
Bitrix\Landing\Rights\setGlobalOn
static setGlobalOn()
Определения
rights.php:116
Bitrix\Landing\Rights\setGlobalOff
static setGlobalOff()
Определения
rights.php:107
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Landing\History
bitrix
modules
landing
lib
Copilot
Generation
Step
TaskSaveBlocksHistory.php
Создано системой
1.14.0