Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractValidator.php
Go to the documentation of this file.
1 <?php
7 
14 abstract class AbstractValidator implements \Magento\Framework\Validator\ValidatorInterface
15 {
19  protected static $_defaultTranslator = null;
20 
24  protected $_translator = null;
25 
31  protected $_messages = [];
32 
40  public static function setDefaultTranslator(\Magento\Framework\Translate\AdapterInterface $translator = null)
41  {
42  self::$_defaultTranslator = $translator;
43  }
44 
51  public static function getDefaultTranslator()
52  {
54  }
55 
62  public function setTranslator($translator = null)
63  {
64  $this->_translator = $translator;
65  return $this;
66  }
67 
73  public function getTranslator()
74  {
75  if ($this->_translator === null) {
77  }
78  return $this->_translator;
79  }
80 
86  public function hasTranslator()
87  {
88  return $this->_translator !== null;
89  }
90 
97  public function getMessages()
98  {
99  return $this->_messages;
100  }
101 
108  public function hasMessages()
109  {
110  return !empty($this->_messages);
111  }
112 
118  protected function _clearMessages()
119  {
120  $this->_messages = [];
121  }
122 
129  protected function _addMessages(array $messages)
130  {
131  $this->_messages = array_merge_recursive($this->_messages, $messages);
132  }
133 }
static setDefaultTranslator(\Magento\Framework\Translate\AdapterInterface $translator=null)