Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
numbergenerator.php
1<?php
3
6
11abstract class NumberGenerator
12{
13 const USER_DEFINED_SYMBOL_START = '{USER_DEFINED:';
15 const SYMBOL_START = '{';
16 const SYMBOL_END = '}';
17
23 public abstract function parseTemplate($template);
24
30 public function parseTemplateForPreview($template)
31 {
32 return $this->parseTemplate($template);
33 }
34
39 public static function getAvailableForType()
40 {
41 throw new NotImplementedException(static::class . ':' . __FUNCTION__ . ' is not implemented');
42 }
43
48 public static function getTemplateWordsForParse()
49 {
50 throw new NotImplementedException(static::class . ':' . __FUNCTION__ . ' is not implemented');
51 }
52
59 public static function getTemplateWordsSettings()
60 {
61 throw new NotImplementedException(static::class . ':' . __FUNCTION__ . ' is not implemented');
62 }
63
71 public static function onGeneratorClassesCollect()
72 {
73 return new EventResult(EventResult::SUCCESS, static::class);
74 }
75
79 public static function getType()
80 {
81 return str_replace('\\', '_', static::class);
82 }
83
90 protected function setFromArrayOrDefault($value, $config, $default = null, $type = null)
91 {
92 if (property_exists(static::class, $value))
93 {
94 if ($config !== null && array_key_exists($value, $config))
95 {
96 if ($type === 'int')
97 {
98 $this->$value = intval($config[$value]);
99 }
100 elseif ($type === 'string')
101 {
102 $this->$value = (string)$config[$value];
103 }
104 elseif ($type === 'bool')
105 {
106 $this->$value = (bool)$config[$value];
107 }
108 else
109 {
110 $this->$value = $config[$value];
111 }
112 }
113 else
114 {
115 $this->$value = $default;
116 }
117 }
118 }
119
124 protected static function getPatternFor($word)
125 {
126 return self::SYMBOL_START . $word . self::SYMBOL_END;
127 }
128}
setFromArrayOrDefault($value, $config, $default=null, $type=null)