Beispiel #1
0
 /**
  * Validate the given value. Looks for the language translation list
  * in the registry (key 'Available_Languages'). If this key is not registered
  * the language list is obtained through a call to getLanguageTranslationList()
  * of Zend_Locale.
  *
  * @param string $value An enum string.
  * @return boolean True if the given enum string is known.
  */
 public function isValid($value)
 {
     if (false === is_array($value)) {
         $value = array($value);
     }
     $registry = Zend_Registry::getInstance();
     if ($registry->isRegistered('Available_Languages')) {
         $translationList = $registry->get('Available_Languages');
     } else {
         $locale = new Zend_Locale();
         $translationList = $locale->getLanguageTranslationList();
     }
     foreach ($value as $val) {
         $this->_setValue($val);
         if (is_string($val) === false) {
             $this->_error(self::MSG_LANGUAGE);
             return false;
         }
         if (array_key_exists($val, $translationList) === false) {
             $this->_error(self::MSG_LANGUAGE);
             return false;
         }
     }
     return true;
 }
Beispiel #2
0
 /**
  * test getLanguageTranslationList
  * expected true
  */
 public function testgetLanguageTranslationList()
 {
     $value = new Zend_Locale();
     $list = $value->getLanguageTranslationList();
     $this->assertTrue(is_array($list));
     $list = $value->getLanguageTranslationList('de');
     $this->assertTrue(is_array($list));
 }