Implementing IteratorAggregate for CakeValidationSet

This commit is contained in:
Jose Lorenzo Rodriguez 2012-05-05 21:13:09 -04:30
parent 6f16a66b83
commit 989a8b8398
2 changed files with 41 additions and 2 deletions

View file

@ -27,7 +27,7 @@ App::uses('CakeRule', 'Model/Validator');
* @package Cake.Model.Validator
* @link http://book.cakephp.org/2.0/en/data-validation.html
*/
class CakeValidationSet implements ArrayAccess {
class CakeValidationSet implements ArrayAccess, IteratorAggregate {
/**
* Holds the ValidationRule objects
@ -284,4 +284,13 @@ class CakeValidationSet implements ArrayAccess {
unset($this->_rules[$index]);
}
}
/**
* Returns an iterator for each of the rules to be applied
*
* @return ArrayIterator
**/
public function getIterator() {
return new ArrayIterator($this->_rules);
}
}