- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/lib/grid/row/actions/item/createcodeitem.php
- Класс: BitrixIblockGridRowActionsItemCreateCodeItem
- Вызов: CreateCodeItem::processCodeTranslitSection
private function processCodeTranslitSection(int $id): Result
{
$result = new Result();
if (!$this->getIblockRightsChecker()->canEditSection($id))
{
$message = Loc::getMessage('IBLOCK_GRID_ROW_ACTIONS_CREATE_CODE_ERROR_ACCESS_DENIED_SECTION', [
'#ID#' => $id,
]);
$result->addError(
new Error($message)
);
return $result;
}
$row = SectionTable::getRow([
'select' => [
'ID',
'NAME',
],
'filter' => [
'=ID' => $id,
'=IBLOCK_ID' => $this->getIblockId(),
],
]);
if (empty($row))
{
return $result;
}
$entity = new CIBlockSection();
$translitSettings = $this->getSectionTranslitSettings();
$fields = [
'CODE' => CUtil::translit(
$row['NAME'],
LANGUAGE_ID,
$translitSettings
),
];
$updateResult = $entity->Update($id, $fields);
if (!$updateResult && $entity->LAST_ERROR)
{
$result->addError(
new Error($entity->LAST_ERROR)
);
}
return $result;
}