Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
validator.php
1<?php
10
14
15Loc::loadMessages(__FILE__);
16
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),
71 );
72 }
73}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
getErrorMessage($value, ORM\Fields\Field $field, $errorPhrase=null, $additionalTemplates=null)
Definition validator.php:50