- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/publicaction/landing.php
- Класс: BitrixLandingPublicActionLanding
- Вызов: Landing::checkAddingInMenu
static function checkAddingInMenu(array $fields, ?bool &$willAdded = null): array
{
$blockId = null;
$menuCode = null;
if (isset($fields['BLOCK_ID']))
{
$blockId = (int)$fields['BLOCK_ID'];
unset($fields['BLOCK_ID']);
}
if (isset($fields['MENU_CODE']))
{
$menuCode = $fields['MENU_CODE'];
unset($fields['MENU_CODE']);
}
if (!$blockId || !$menuCode || !is_string($menuCode))
{
return $fields;
}
$willAdded = true;
LandingCore::callback('OnAfterAdd',
function(BitrixMainEvent $event) use ($blockId, $menuCode)
{
$primary = $event->getParameter('primary');
$fields = $event->getParameter('fields');
if ($primary)
{
$landingId = BlockCore::getLandingIdByBlockId($blockId);
if ($landingId)
{
$updateData = [
$menuCode => [
[
'text' => $fields['TITLE'],
'href' => '#landing' . $primary['ID']
]
]
];
Block::updateNodes(
$landingId,
$blockId,
$updateData,
['appendMenu' => true]
);
}
}
}
);
return $fields;
}