conveience method inspect() in Doctrine_Validator_Exception. Call it with user_func and it will apply it to all ErrorStacks
This commit is contained in:
parent
3ad6e01c73
commit
8fbd18207b
@ -184,7 +184,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
||||
}
|
||||
}
|
||||
|
||||
$this->_errorStack = new Doctrine_Validator_ErrorStack();
|
||||
$this->_errorStack = new Doctrine_Validator_ErrorStack(get_class($this));
|
||||
|
||||
$repository = $this->_table->getRepository();
|
||||
$repository->add($this);
|
||||
|
@ -39,13 +39,16 @@ class Doctrine_Validator_ErrorStack extends Doctrine_Access implements Countable
|
||||
* @var array
|
||||
*/
|
||||
protected $errors = array();
|
||||
protected $classname = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{}
|
||||
public function __construct($classname = "")
|
||||
{
|
||||
$this->classname = $classname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an error to the stack.
|
||||
@ -127,4 +130,12 @@ class Doctrine_Validator_ErrorStack extends Doctrine_Access implements Countable
|
||||
{
|
||||
return count($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the classname where the errors occured
|
||||
*
|
||||
*/
|
||||
public function getClassname(){
|
||||
return $this->classname;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,9 @@ class Doctrine_Validator_Exception extends Doctrine_Exception implements Countab
|
||||
return parent::__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a message with all classes that have exceptions
|
||||
*/
|
||||
private function generateMessage()
|
||||
{
|
||||
$message = "";
|
||||
@ -79,4 +82,17 @@ class Doctrine_Validator_Exception extends Doctrine_Exception implements Countab
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will apply the value of the $function variable as a user_func
|
||||
* to tall errorstack objects in the exception
|
||||
*
|
||||
* @param mixed Either string with function name or array with object,
|
||||
* functionname. See call_user_func in php manual for more inforamtion
|
||||
*/
|
||||
public function inspect($function){
|
||||
foreach($this->invalid as $record){
|
||||
call_user_func($function, $record->getErrorStack());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user