Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
randomnumbergenerator.php
1
<?
2
namespace
Bitrix\Main\Numerator\Generator
;
3
4
use
Bitrix\Main\Localization\Loc
;
5
use
Bitrix\Main\Numerator\Generator\Contract\UserConfigurable
;
6
use
Bitrix\Main\Result
;
7
8
Loc::loadMessages
(__FILE__);
9
14
class
RandomNumberGenerator
extends
NumberGenerator
implements
UserConfigurable
15
{
16
protected
$length
;
17
const
TEMPLATE_WORD_RANDOM
=
'RANDOM'
;
18
20
public
function
setConfig
($config)
21
{
22
$this->
setFromArrayOrDefault
(
'length'
, $config, 5,
'int'
);
23
}
24
26
public
function
getConfig
()
27
{
28
return
[
'length'
=>
$this->length
,];
29
}
30
32
public
function
parseTemplate
($template)
33
{
34
return
str_replace(static::getPatternFor(static::TEMPLATE_WORD_RANDOM), $this->generateRandomString(), $template);
35
}
36
38
public
static
function
getTemplateWordsForParse
()
39
{
40
return
[static::getPatternFor(static::TEMPLATE_WORD_RANDOM)];
41
}
42
46
private
function
generateRandomString()
47
{
48
return
randString($this->length, [
'ABCDEFGHIJKLNMOPQRSTUVWXYZ'
,
'0123456789'
]);
49
}
50
54
public
static
function
getAvailableForType
()
55
{
56
return
'DEFAULT'
;
57
}
58
60
public
static
function
getTemplateWordsSettings
()
61
{
62
return
[
63
static::getPatternFor(static::TEMPLATE_WORD_RANDOM) =>
64
Loc::getMessage
(
'BITRIX_MAIN_NUMERATOR_GENERATOR_RANDOMNUMBERGENERATOR_WORD_RANDOM'
),
65
];
66
}
67
69
public
static
function
getSettingsFields
()
70
{
71
return
[
72
[
73
'settingName'
=>
'length'
,
74
'type'
=>
'int'
,
75
'default'
=> 5,
76
'title'
=>
Loc::getMessage
(
'TITLE_BITRIX_MAIN_NUMERATOR_GENERATOR_RANDOMNUMBERGENERATOR_LENGTH'
),
77
],
78
];
79
}
80
82
public
function
validateConfig
($config)
83
{
84
$result =
new
Result
();
85
return
$result;
86
}
87
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Numerator\Generator\NumberGenerator
Definition
numbergenerator.php:12
Bitrix\Main\Numerator\Generator\NumberGenerator\setFromArrayOrDefault
setFromArrayOrDefault($value, $config, $default=null, $type=null)
Definition
numbergenerator.php:90
Bitrix\Main\Numerator\Generator\RandomNumberGenerator
Definition
randomnumbergenerator.php:15
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\TEMPLATE_WORD_RANDOM
const TEMPLATE_WORD_RANDOM
Definition
randomnumbergenerator.php:17
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\validateConfig
validateConfig($config)
Definition
randomnumbergenerator.php:82
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\getConfig
getConfig()
Definition
randomnumbergenerator.php:26
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\getAvailableForType
static getAvailableForType()
Definition
randomnumbergenerator.php:54
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\getTemplateWordsForParse
static getTemplateWordsForParse()
Definition
randomnumbergenerator.php:38
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\parseTemplate
parseTemplate($template)
Definition
randomnumbergenerator.php:32
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\$length
$length
Definition
randomnumbergenerator.php:16
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\getTemplateWordsSettings
static getTemplateWordsSettings()
Definition
randomnumbergenerator.php:60
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\getSettingsFields
static getSettingsFields()
Definition
randomnumbergenerator.php:69
Bitrix\Main\Numerator\Generator\RandomNumberGenerator\setConfig
setConfig($config)
Definition
randomnumbergenerator.php:20
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Main\Numerator\Generator\Contract\UserConfigurable
Definition
userconfigurable.php:12
Bitrix\Main\Numerator\Generator
modules
main
lib
numerator
generator
randomnumbergenerator.php
Создано системой
1.10.0