/** * Adds an incident to the validation result. This will automatically adjust * the argument result table (which is required because one can still * manually add errors either via addError or by directly using this method) * * @param AgaviValidationIncident The incident. * * @author Dominik del Bondio <*****@*****.**> * @since 1.0.0 */ public function addIncident(AgaviValidationIncident $incident) { // we need to add the fields to our fieldresults if they don't exist there // yet and adjust our result if needed (which only happens when this method // is called not from a validator) $severity = $incident->getSeverity(); $validator = $incident->getValidator(); if ($severity > $this->result || null === $this->result) { $this->result = $severity; } // store the result for the argument if it's not stored yet foreach ($incident->getArguments() as $argument) { $this->addArgumentResult($argument, $severity, $validator); } $this->incidents[$validator ? $validator->getName() : ''][] = $incident; }
/** * Set an array of errors * * If an existing error name matches any of the keys in the supplied * array, the associated message will be appended to the messages array. * * @param array An associative array of errors and their associated * messages. * * @author Dominik del Bondio <*****@*****.**> * @since 0.9.0 * * @deprecated 1.0.0 */ public function setErrors(array $errors) { $incident = new AgaviValidationIncident(null, AgaviValidator::ERROR); foreach ($errors as $name => $error) { $name = new AgaviValidationArgument($name); $incident->addError(new AgaviValidationError($error, null, array($name))); } $this->addIncident($incident); }