Bitrix API

Numerator

Class Numerator - generates numbers based on config, is used for creating random, sequential numbers, also may contain prefix, date values etc.

Table of Contents

Constants

NUMERATOR_ALL_GENERATORS_TYPE  = 'ALL'
NUMERATOR_DEFAULT_TYPE  = 'DEFAULT'

Methods

create()  : static
return empty numerator object with no configuration
delete()  : $this|DeleteResult|Result
getConfig()  : array<string|int, mixed>
return numerator's configuration with filled in values for every setting
getId()  : mixed
getListByType()  : array<string|int, mixed>
getNext()  : string
return next number. If numerator has {NUMBER} in template, Sequential counter value in database will be updated If you need next number for preview only, use previewNextNumber
getOneByType()  : array<string|int, mixed>|null
Returns numerator related fields from db by its type (use it in case of only single one exists for the type)
getSettingsFields()  : mixed
getTemplateWordsForType()  : array<string|int, mixed>
returns all template words for creating new numerator depending on its type
getType()  : string
type string used as key in configuration arrays
hasSequentialNumber()  : bool
check if numerator has {NUMBER} in template
load()  : null|static
Load numerator by id
loadByCode()  : static|null
previewNextNumber()  : string
return next number, without updating database value (for numerator with sequential number)
previewNextSequentialNumber()  : int|null
returns next sequential number, if numerator has sequence, null if it hasn't not increases the sequent number
save()  : AddResult|UpdateResult
setConfig()  : Result
sets configuration for numerator and validates settings
setDynamicConfig()  : mixed
setHash()  : mixed
setNextSequentialNumber()  : Result
The only way to affect the NEXT number - function forces the numerator to start counting with a given number
update()  : AddResult|UpdateResult|Result

Constants

NUMERATOR_ALL_GENERATORS_TYPE

public mixed NUMERATOR_ALL_GENERATORS_TYPE = 'ALL'

NUMERATOR_DEFAULT_TYPE

public mixed NUMERATOR_DEFAULT_TYPE = 'DEFAULT'

Methods

create()

return empty numerator object with no configuration

public static create() : static
Return values
static

delete()

public static delete(mixed $id) : $this|DeleteResult|Result
Parameters
$id : mixed
Tags
throws
Exception
Return values
$this|DeleteResult|Result

getConfig()

return numerator's configuration with filled in values for every setting

public getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

getListByType()

public static getListByType([string $type = null ][, null $sort = null ]) : array<string|int, mixed>
Parameters
$type : string = null
$sort : null = null
Tags
throws
ArgumentException
throws
ObjectPropertyException
throws
SystemException
Return values
array<string|int, mixed>

getNext()

return next number. If numerator has {NUMBER} in template, Sequential counter value in database will be updated If you need next number for preview only, use previewNextNumber

public getNext([string|int $hash = null ]) : string
Parameters
$hash : string|int = null
  • you can reuse one numerator in various cases (for various companies etc.) by passing different hashes to it. For Sequential number it means using independent counters for every hash Hash will be ignored here, if it was already set in Load method or via setHash
Tags
see
Numerator::setHash()
see
Numerator::previewNextNumber()
Return values
string

getOneByType()

Returns numerator related fields from db by its type (use it in case of only single one exists for the type)

public static getOneByType([string $type = null ]) : array<string|int, mixed>|null
Parameters
$type : string = null
Tags
throws
ArgumentException
throws
ObjectPropertyException
throws
SystemException
Return values
array<string|int, mixed>|null

getSettingsFields()

public static getSettingsFields(mixed $numeratorType) : mixed
Parameters
$numeratorType : mixed
Tags
throws
ArgumentException
throws
NotImplementedException
throws
ObjectPropertyException
throws
SystemException

getTemplateWordsForType()

returns all template words for creating new numerator depending on its type

public static getTemplateWordsForType([string $isAvailableByType = null ]) : array<string|int, mixed>
Parameters
$isAvailableByType : string = null
Tags
throws
NotImplementedException
Return values
array<string|int, mixed>

getType()

type string used as key in configuration arrays

public static getType() : string
Return values
string

hasSequentialNumber()

check if numerator has {NUMBER} in template

public hasSequentialNumber() : bool
Return values
bool

load()

Load numerator by id

public static load(mixed $numeratorId[, mixed $source = null ]) : null|static
Parameters
$numeratorId : mixed
$source : mixed = null
  • optional, numerator dynamicConfig for generating next number, also can be Hashable ancestor for set up hash for numerator
Tags
throws
ArgumentException
throws
ObjectPropertyException
throws
SystemException
see
Numerator::getNext()
Return values
null|static

loadByCode()

public static loadByCode(mixed $code[, mixed $source = null ]) : static|null
Parameters
$code : mixed
$source : mixed = null
Return values
static|null

previewNextNumber()

return next number, without updating database value (for numerator with sequential number)

public previewNextNumber([null $hash = null ]) : string
Parameters
$hash : null = null
Return values
string

previewNextSequentialNumber()

returns next sequential number, if numerator has sequence, null if it hasn't not increases the sequent number

public previewNextSequentialNumber([string $hash = null ]) : int|null
Parameters
$hash : string = null
Return values
int|null

save()

public save() : AddResult|UpdateResult
Tags
throws
ArgumentException
throws
ObjectException
throws
ObjectPropertyException
throws
SystemException
Return values
AddResult|UpdateResult

setConfig()

sets configuration for numerator and validates settings

public setConfig(mixed $config) : Result
Parameters
$config : mixed
Tags
throws
NotImplementedException
Return values
Result
  • message that can be shown to an end user

setDynamicConfig()

public setDynamicConfig(mixed $dynamicConfig) : mixed
Parameters
$dynamicConfig : mixed
  • anything (array|object|..) that will be used by DynamicConfigurable generators of Numerator for parsing template and creating number

setHash()

public setHash(mixed $hashable) : mixed
Parameters
$hashable : mixed
  • object that returns hash string Used for Numerators containing Sequential number Hash can be set once, will be ignored here, if it was already set Typically hash is a string like COMPANY_64, or USER_42

setNextSequentialNumber()

The only way to affect the NEXT number - function forces the numerator to start counting with a given number

public setNextSequentialNumber(int $nextNumber[, mixed $whereNumber = null ][, string $hash = null ]) : Result
Parameters
$nextNumber : int
$whereNumber : mixed = null
  • old value of next number
$hash : string = null
Return values
Result

update()

public static update(mixed $numId, mixed $config) : AddResult|UpdateResult|Result
Parameters
$numId : mixed
$config : mixed
  • same configuration structure as using via setConfig method
Tags
throws
ArgumentException
throws
NotImplementedException
throws
ObjectException
throws
ObjectPropertyException
throws
SystemException
Return values
AddResult|UpdateResult|Result

        
On this page

Search results