• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblockelement.php
  • Класс: CAllIBlockElement
  • Вызов: CAllIBlockElement::createMnemonicCode
public function createMnemonicCode(array $element, array $options = []): ?string
{
	if (!isset($element['NAME']) || $element['NAME'] === '')
	{
		return null;
	}
	$iblockId = $element['IBLOCK_ID'] ?? 0;
	if ($iblockId !== null)
	{
		$iblockId = (int)$iblockId;
	}
	if ($iblockId <= 0)
	{
		return null;
	}

	if ($this->iblock !== null && $this->iblock['ID'] === $iblockId)
	{
		$iblock = $this->iblock;
	}
	else
	{
		$iblock = CIBlock::GetArrayByID($iblockId);
	}

	if (empty($iblock))
	{
		return null;
	}

	$code = null;
	if (isset($iblock['FIELDS']['CODE']['DEFAULT_VALUE']))
	{
		$code = $this->generateMnemonicCode($element['NAME'], $iblockId, $options);
		if ($code === null)
		{
			return null;
		}

		if ($iblock['FIELDS']['CODE']['DEFAULT_VALUE']['TRANSLITERATION'] === 'Y'
			&& (
				$iblock['FIELDS']['CODE']['DEFAULT_VALUE']['UNIQUE'] === 'Y'
				|| ($options['CHECK_UNIQUE'] ?? 'N') === 'Y'
			)
		)
		{
			$id = (int)$element['ID'] ?? null;

			$code = $this->getUniqueMnemonicCode(
				$code,
				$id,
				$iblockId,
				$options
			);
		}
	}

	return $code;
}