- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/numerator/model/numerator.php
- Класс: BitrixMainNumeratorModelNumeratorTable
- Вызов: NumeratorTable::getMap
static function getMap()
{
return [
(new IntegerField('ID'))
->configurePrimary(true)
->configureAutocomplete(true)
,
(new StringField('NAME'))
->configureRequired(true)
,
(new StringField('TEMPLATE'))
->configureRequired(true)
,
(new StringField('SETTINGS'))
->configureRequired(true)
,
(new StringField('TYPE'))
->configureDefaultValue('DEFAULT')
,
new DatetimeField('CREATED_AT'),
new IntegerField('CREATED_BY'),
new DatetimeField('UPDATED_AT'),
new IntegerField('UPDATED_BY'),
(new StringField('CODE'))
->configureSize(255)
->configureUnique()
->configureNullable()
->addValidator(static function($value) {
if (is_null($value) || (is_string($value) && !empty($value)))
{
return true;
}
return 'CODE should be either NULL or non-empty string';
})
->addValidator(static function($value, $primary) {
if (!is_string($value))
{
return true;
}
$existingId = self::getIdByCode($value);
if (!$existingId)
{
// no rows with this code exists
return true;
}
$id = (int)($primary['ID'] ?? 0);
if ($id > 0 && $id === $existingId)
{
return true;
}
return 'Entry with the same CODE already exists';
})
,
];
}