- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/urlrewrite.php
- Класс: BitrixLandingUrlRewrite
- Вызов: UrlRewrite::set
static function set($siteId, $rule, $landingId = null)
{
$rule = trim($rule);
// check for exist
$check = SiteTable::getList([
'select' => [
'ID'
],
'filter' => [
'ID' => $siteId,
'=DELETED' => ['Y', 'N']
]
])->fetch();
if (!$check)
{
return;
}
if ($landingId)
{
$check = SiteTable::getList([
'select' => [
'ID'
],
'filter' => [
'ID' => $landingId,
'=DELETED' => ['Y', 'N']
]
])->fetch();
if (!$check)
{
return;
}
}
// set or unset
$filter = [
'SITE_ID' => $siteId,
'=RULE' => $rule
];
if ($landingId)
{
$filter['!LANDING_ID'] = $landingId;
}
$res = UrlRewriteTable::getList([
'select' => [
'ID'
],
'filter' => $filter
]);
if ($row = $res->fetch())
{
if ($landingId)
{
UrlRewriteTable::update($row['ID'], [
'LANDING_ID' => $landingId
]);
}
else
{
UrlRewriteTable::delete(
$row['ID']
);
}
}
else if ($landingId)
{
UrlRewriteTable::add([
'SITE_ID' => $siteId,
'RULE' => $rule,
'LANDING_ID' => $landingId
]);
}
}