- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/lib/CustomSection/Entity/CodeGenerator.php
- Класс: BitrixIntranetCustomSectionEntityCodeGenerator
- Вызов: CodeGenerator::generateByTitle
protected function generateByTitle(string $title, int $try = 1): ?string
{
if ($try >= static::MAX_NUMBER_OF_TRIES)
{
return null;
}
if ($try > 1)
{
//e.g. 'Not unique title 2'
$title .= ' ' . $try;
}
$code = CUtil::translit(
$title,
Loc::getCurrentLang(),
[
'max_len' => $this->codeField->getSize(),
'change_case' => true,
'replace_space' => '_',
'replace_other' => '',
'delete_repeat_replace' => true,
'safe_chars' => '',
]
);
if ($this->isCodeShouldBeUnique() && !$this->isCodeUnique($code))
{
return $this->generateByTitle($title, $try + 1);
}
return $code;
}