Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
field.php
1<?php
2namespace Bitrix\Landing;
3
4abstract class Field
5{
10 protected $id;
11
16 protected $code;
17
22 protected $value;
23
28 protected $title;
29
34 protected $default;
35
40 protected $help;
41
46 protected $htmlHelp;
47
52 protected $searchable = false;
53
58 protected $fetchModificator = null;
59
65 public function __construct($code, array $params = array())
66 {
67 $this->code = mb_strtoupper($code);
68 $this->value = null;
69 $this->id = isset($params['id']) ? $params['id'] : '';
70 $this->title = isset($params['title']) ? $params['title'] : '';
71 $this->default = isset($params['default']) ? $params['default'] : null;
72 $this->help = isset($params['help']) ? $params['help'] : '';
73 $this->htmlHelp = isset($params['htmlHelp']) ? $params['htmlHelp'] : false;
74 $this->searchable = isset($params['searchable']) && $params['searchable'] === true;
75 $this->fetchModificator = isset($params['fetch_data_modification']) ? $params['fetch_data_modification'] : null;
76 }
77
82 public function isEmptyValue()
83 {
84 return $this->value === null;
85 }
86
92 public function setValue($value)
93 {
94 $this->value = $value;
95 }
96
101 public function getValue()
102 {
103 if (is_callable($this->fetchModificator))
104 {
105 return call_user_func_array(
106 $this->fetchModificator,
107 [$this->value]
108 );
109 }
110 return $this->value;
111 }
112
117 public function getHelpValue()
118 {
119 return $this->help;
120 }
121
126 public function isHtmlHelp()
127 {
128 return $this->htmlHelp === true;
129 }
130
135 public function isSearchable()
136 {
137 return $this->searchable;
138 }
139
145 public function setCode($code)
146 {
147 $this->code = mb_strtoupper($code);
148 }
149
154 public function getCode()
155 {
156 return $this->code;
157 }
158
163 public function getLabel()
164 {
165 return $this->title;
166 }
167
172 public function getType()
173 {
174 $class = explode('\\', get_called_class());
175 return mb_strtolower(array_pop($class));
176 }
177
182 public function __toString()
183 {
184 return $this->value ? (string)$this->value : (string)$this->default;
185 }
186
195 abstract public function viewForm(array $params = array());
196}
__construct($code, array $params=array())
Definition field.php:65
viewForm(array $params=array())