public function validate(CM_Frontend_Environment $environment, $userInput) { if (!$this->_tree->findNodeById($userInput)) { throw new CM_Exception_FormFieldValidation(new CM_I18n_Phrase('Invalid value')); } return $userInput; }
/** * @param string $languageKey * @throws CM_Exception_Invalid */ private function _addLanguageNode($languageKey) { if (!preg_match('#^(.*)\\.([^\\.]+)$#', $languageKey, $matches)) { throw new CM_Exception_Invalid('Invalid Language Key found: `' . $languageKey . '`'); } list($id, $parentId, $name) = $matches; if ($parentId && !array_key_exists($parentId, $this->_nodesTmp)) { $this->_addLanguageNode($parentId); } if (!$parentId) { $parentId = $this->_rootId; } parent::_addNode($id, $name, $parentId); }