- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/hook.php
- Класс: BitrixLandingHook
- Вызов: Hook::publicationWithSkipNeededPublication
static function publicationWithSkipNeededPublication($id, $type): void
{
$editModeBack = self::$editMode;
self::$editMode = false;
$publicData = self::getData($id, $type, true);
self::$editMode = $editModeBack;
if ($type === self::ENTITY_TYPE_SITE)
{
self::publicationSite($id);
}
if ($type === self::ENTITY_TYPE_LANDING)
{
self::publicationLanding($id);
}
$data = self::getData($id, $type, true);
// return previously public values
$needClearCache = false;
foreach (self::getList($id, $type) as $hook)
{
if ($hook->isNeedPublication())
{
$fieldsToDelete = [];
if (isset($publicData[$hook->getCode()]))
{
foreach ($data[$hook->getCode()] as $fieldCode => $field)
{
if (!isset($publicData[$hook->getCode()][$fieldCode]))
{
$fieldsToDelete[$fieldCode] = $field;
}
elseif ($publicData[$hook->getCode()][$fieldCode]['VALUE'] !== $field['VALUE'])
{
$needClearCache = true;
HookData::update($field['ID'],
[
'VALUE' => $field['VALUE'],
]
);
}
}
}
else
{
$fieldsToDelete = $data[$hook->getCode()] ?? [];
}
// del if not exists in public
if (!empty($fieldsToDelete))
{
$needClearCache = true;
foreach ($fieldsToDelete as $fieldCode => $field)
{
$res = HookData::getList([
'select' => ['ID'],
'filter' => [
'ENTITY_ID' => $id,
'=ENTITY_TYPE' => $type,
'=HOOK' => $hook->getCode(),
'=CODE' => $fieldCode,
'=PUBLIC' => 'Y'
]
]);
if ($row = $res->fetch())
{
HookData::delete($row['ID']);
}
}
}
}
}
// drop public cache
if ($needClearCache)
{
if ($type === self::ENTITY_TYPE_SITE)
{
$landings = Landing::getList([
'select' => ['ID'],
'filter' => [
'SITE_ID' => $id,
'=PUBLIC' => 'Y',
'=DELETED' => 'N',
],
]);
while ($landing = $landings->fetch())
{
Landing::update($landing['ID'], ['PUBLIC' => 'N']);
}
}
if ($type === self::ENTITY_TYPE_LANDING)
{
Landing::update($id, ['PUBLIC' => 'N']);
}
}
}