|
|
@@ -14,11 +14,13 @@
|
|
|
*/
|
|
|
namespace Cake\ORM;
|
|
|
|
|
|
+use ArrayIterator;
|
|
|
use Cake\ORM\Association;
|
|
|
use Cake\ORM\AssociationsNormalizerTrait;
|
|
|
use Cake\ORM\Entity;
|
|
|
use Cake\ORM\Table;
|
|
|
use InvalidArgumentException;
|
|
|
+use IteratorAggregate;
|
|
|
|
|
|
/**
|
|
|
* A container/collection for association classes.
|
|
|
@@ -26,7 +28,7 @@ use InvalidArgumentException;
|
|
|
* Contains methods for managing associations, and
|
|
|
* ordering operations around saving and deleting.
|
|
|
*/
|
|
|
-class AssociationCollection
|
|
|
+class AssociationCollection implements IteratorAggregate
|
|
|
{
|
|
|
|
|
|
use AssociationsNormalizerTrait;
|
|
|
@@ -292,4 +294,14 @@ class AssociationCollection
|
|
|
|
|
|
return $this->_normalizeAssociations($keys);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Allow looping through the associations
|
|
|
+ *
|
|
|
+ * @return ArrayIterator
|
|
|
+ */
|
|
|
+ public function getIterator()
|
|
|
+ {
|
|
|
+ return new ArrayIterator($this->_items);
|
|
|
+ }
|
|
|
}
|