/** * Throw validation exception * * @param string $short_error_name * @param string $long_error_name * @param array|null $arguments * @param mixed $value */ protected final function error($short_error_name, $long_error_name, $arguments, $value) { assert('is_string($short_error_name)'); assert('is_string($long_error_name)'); assert('is_null($arguments) || is_array($arguments)'); // add options to $arguments if (!is_array($arguments)) { $arguments = array(); } $arguments = array_merge($this->_options, $arguments); // get error format $short_error_key = $short_error_name . '_error'; if (!($format = $this->getOption($short_error_key))) { $long_error_key = $long_error_name . '_error'; $format = FWI18N::get('FWFormValidator', $long_error_key); if (!$format) { $format = 'is invalid'; } } // generate message $search = $replace = array(); foreach ($arguments as $s => $r) { if (!is_object($r) && !is_array($r)) { $search[] = '{' . $s . '}'; $replace[] = $r; } } $message = str_replace($search, $replace, $format); // throw exception $e = new FWFormValidationException($message); $e->sanitizedValue = $value; throw $e; }