Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
validator.php
1
<?php
9
namespace
Bitrix\Main\ORM\Fields\Validators
;
10
11
use
Bitrix\Main\ORM
;
12
use
Bitrix\Main\ArgumentTypeException
;
13
use
Bitrix\Main\Localization\Loc
;
14
15
Loc::loadMessages
(__FILE__);
16
17
abstract
class
Validator
implements
ORM\Fields\Validators\IValidator
18
{
22
protected
$errorPhraseCode
=
'MAIN_ENTITY_VALIDATOR'
;
23
protected
$errorPhrase
;
24
29
public
function
__construct
(
$errorPhrase
=
null
)
30
{
31
if
(
$errorPhrase
!==
null
&& !is_string(
$errorPhrase
))
32
{
33
throw
new
ArgumentTypeException
(
'errorPhrase'
,
'string'
);
34
}
35
36
if
(
$errorPhrase
!==
null
)
37
{
38
$this->errorPhrase =
$errorPhrase
;
39
}
40
}
41
50
protected
function
getErrorMessage
($value, ORM\Fields\
Field
$field,
$errorPhrase
=
null
, $additionalTemplates =
null
)
51
{
52
if
(
$errorPhrase
===
null
)
53
{
54
$errorPhrase
= ($this->errorPhrase !==
null
? $this->errorPhrase :
Loc::getMessage
($this->errorPhraseCode));
55
}
56
57
$langValues = array(
58
'#VALUE#'
=> $value,
59
'#FIELD_NAME#'
=> $field->getName(),
60
'#FIELD_TITLE#'
=> $field->getTitle()
61
);
62
if
(is_array($additionalTemplates))
63
{
64
$langValues += $additionalTemplates;
65
}
66
67
return
str_replace(
68
array_keys($langValues),
69
array_values($langValues),
70
$errorPhrase
71
);
72
}
73
}
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
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\ORM\Fields\Field
Definition
field.php:25
Bitrix\Main\ORM\Fields\Validators\Validator
Definition
validator.php:18
Bitrix\Main\ORM\Fields\Validators\Validator\getErrorMessage
getErrorMessage($value, ORM\Fields\Field $field, $errorPhrase=null, $additionalTemplates=null)
Definition
validator.php:50
Bitrix\Main\ORM\Fields\Validators\Validator\$errorPhraseCode
$errorPhraseCode
Definition
validator.php:22
Bitrix\Main\ORM\Fields\Validators\Validator\$errorPhrase
$errorPhrase
Definition
validator.php:23
Bitrix\Main\ORM\Fields\Validators\Validator\__construct
__construct($errorPhrase=null)
Definition
validator.php:29
Bitrix\Main\ORM\Fields\Validators\IValidator
Definition
ivalidator.php:15
Bitrix\Main\ORM\Fields\Validators
Definition
booleanvalidator.php:9
Bitrix\Main\ORM
modules
main
lib
orm
fields
validators
validator.php
Создано системой
1.10.0