|
|
@@ -17,6 +17,7 @@ namespace Cake\ORM;
|
|
|
use ArrayIterator;
|
|
|
use Cake\Datasource\EntityInterface;
|
|
|
use Cake\ORM\Locator\LocatorAwareTrait;
|
|
|
+use Cake\ORM\Locator\LocatorInterface;
|
|
|
use InvalidArgumentException;
|
|
|
use IteratorAggregate;
|
|
|
|
|
|
@@ -40,6 +41,21 @@ class AssociationCollection implements IteratorAggregate
|
|
|
protected $_items = [];
|
|
|
|
|
|
/**
|
|
|
+ * Constructor.
|
|
|
+ *
|
|
|
+ * Sets the default table locator for associations.
|
|
|
+ * If no locator is provided, the global one will be used.
|
|
|
+ *
|
|
|
+ * @param \Cake\ORM\Locator\LocatorInterface|null $tableLocator Table locator instance.
|
|
|
+ */
|
|
|
+ public function __construct(LocatorInterface $tableLocator = null)
|
|
|
+ {
|
|
|
+ if ($tableLocator !== null) {
|
|
|
+ $this->_tableLocator = $tableLocator;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Add an association to the collection
|
|
|
*
|
|
|
* If the alias added contains a `.` the part preceding the `.` will be dropped.
|