/** * @param CM_Frontend_Environment $environment * @param string $userInput * @throws CM_Exception_FormFieldValidation * @return CM_Model_Location */ public function validate(CM_Frontend_Environment $environment, $userInput) { $value = parent::validate($environment, $userInput); $value = CM_Params::jsonDecode($value); $location = CM_Model_Location::fromArray($value); if ($location->getLevel() < $this->_options['levelMin'] || $location->getLevel() > $this->_options['levelMax']) { throw new CM_Exception_FormFieldValidation(new CM_I18n_Phrase('Invalid location level.')); } return $location; }
public function testArrayConvertible() { $location = CMTest_TH::createLocation(); $this->assertEquals($location, CM_Model_Location::fromArray($location->toArray())); }