Example #1
0
 /**
  * Set translation object
  *
  * @param  Zend_Translate|\Zend\Translate\Adapter\Adapter|null $translator
  * @return \Zend\Validator\AbstractValidator
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator || $translator instanceof Translator\Adapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof Translator\Translator) {
         $this->_translator = $translator->getAdapter();
     } else {
         throw new Exception('Invalid translator specified');
     }
     return $this;
 }
Example #2
0
 /**
  * Set default translation object for all validate objects
  *
  * @param  Zend_Translate|\Zend\Translate\Adapter\Adapter|null $translator
  * @return void
  */
 public static function setDefaultTranslator($translator = null)
 {
     if (null === $translator || $translator instanceof Adapter\Adapter) {
         self::$_defaultTranslator = $translator;
     } elseif ($translator instanceof Translate\Translator) {
         self::$_defaultTranslator = $translator->getAdapter();
     } else {
         throw new Exception('Invalid translator specified');
     }
 }