123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- namespace Cube\Validate;
- use Cube\Controller\Front,
- Cube\Translate,
- Cube\Translate\Adapter\AbstractAdapter as TranslateAdapter;
- abstract class AbstractValidate
- {
-
- protected $_message;
-
- protected $_name;
-
- protected $_value;
-
- protected $_translate;
-
- public function getMessage()
- {
- $translate = $this->getTranslate();
- if (null !== $translate) {
- return $translate->_($this->_message);
- }
- return $this->_message;
- }
-
- public function setMessage($message)
- {
- $this->_message = (string)$message;
- return $this;
- }
-
- public function resetMessage()
- {
- $this->_message = null;
- return $this;
- }
-
- public function getName()
- {
- return $this->_name;
- }
-
- public function setName($name)
- {
- $this->_name = (string)$name;
- return $this;
- }
-
- public function getValue()
- {
- return $this->_value;
- }
-
- public function setValue($value)
- {
- $this->_value = $value;
- return $this;
- }
-
- public function setTranslate(TranslateAdapter $translate)
- {
- $this->_translate = $translate;
- return $this;
- }
-
- public function getTranslate()
- {
- if (!$this->_translate instanceof TranslateAdapter) {
- $translate = Front::getInstance()->getBootstrap()->getResource('translate');
- if ($translate instanceof Translate) {
- $this->setTranslate(
- $translate->getAdapter());
- }
- }
- return $this->_translate;
- }
-
- abstract public function isValid();
- }
|