Doctrine_Record::getErrorStack PHP Méthode

getErrorStack() public méthode

retrieves the ErrorStack. To be called after a failed validation attempt (@see isValid()).
public getErrorStack ( ) : Doctrine_Validator_ErrorStack
Résultat Doctrine_Validator_ErrorStack returns the errorStack associated with this record
    public function getErrorStack()
    {
        if (!$this->_errorStack) {
            $this->_errorStack = new Doctrine_Validator_ErrorStack(get_class($this));
        }
        return $this->_errorStack;
    }

Usage Example

Exemple #1
0
 /**
  * Validates all the unique indexes.
  *
  * This methods validates 'unique' sets of fields for the given Doctrine_Record instance.
  * Pushes error to the record error stack if they are generated.
  *
  * @param Doctrine_Record $record
  */
 public function validateUniques(Doctrine_Record $record)
 {
     $errorStack = $record->getErrorStack();
     $validator = Doctrine_Validator::getValidator('unique');
     $validator->invoker = $record;
     foreach ($this->_uniques as $unique) {
         list($fields, $options) = $unique;
         $validator->args = $options;
         $validator->field = $fields;
         $values = array();
         foreach ($fields as $field) {
             $values[] = $record->{$field};
         }
         if (!$validator->validate($values)) {
             foreach ($fields as $field) {
                 $errorStack->add($field, $validator);
             }
         }
     }
 }
All Usage Examples Of Doctrine_Record::getErrorStack