• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/History/Action/ReplaceLanding.php
  • Класс: BitrixLandingHistoryActionReplaceLanding
  • Вызов: ReplaceLanding::execute
public function execute(bool $undo = true): bool
{
	$landing = Landing::createInstance($this->params['lid']);
	if ($landing->exist())
	{
		foreach ($landing->getBlocks() as $block)
		{
			$accessBefore = $block->getAccess();
			$block->setAccess(Block::ACCESS_X);

			$landing->markDeletedBlock($block->getId(), true);

			$block->setAccess($accessBefore);
		}

		// return blocks
		$blocksToUndelete = $undo ? $this->params['blocksBefore'] : $this->params['blocksAfter'];
		foreach ($blocksToUndelete as $blockId)
		{
			$block = new Block($blockId);
			$accessBefore = $block->getAccess();
			$block->setAccess(Block::ACCESS_X);
			$landing->addBlockToCollection($block);

			$landing->markDeletedBlock($blockId, false);

			$block->setAccess($accessBefore);
		}

		// return additional fields
		$fields = $undo ? $this->params['additionalFieldsBefore'] : $this->params['additionalFieldsAfter'];
		Landing::saveAdditionalFields($this->params['lid'], $fields);

		if (
			Manager::isAutoPublicationEnabled()
			&& $landing->getError()->isEmpty()
		)
		{
			$landing->publication();
		}

		return true;
	}

	return false;
}