diff --git a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php index a541e3b6b..a23721f31 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php @@ -19,9 +19,7 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\PersistentCollection; /** * Base class for all collection persisters. @@ -73,76 +71,4 @@ abstract class AbstractCollectionPersister implements CollectionPersister $this->platform = $this->conn->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); } - - /** - * {@inheritdoc} - */ - public function delete(PersistentCollection $coll) - { - throw new \BadMethodCallException("Deleting elements is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function count(PersistentCollection $coll) - { - throw new \BadMethodCallException("Counting the size of this persistent collection is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function slice(PersistentCollection $coll, $offset, $length = null) - { - throw new \BadMethodCallException("Slicing elements is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function contains(PersistentCollection $coll, $element) - { - throw new \BadMethodCallException("Checking for existence of an element is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function containsKey(PersistentCollection $coll, $key) - { - throw new \BadMethodCallException("Checking for existence of a key is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function removeElement(PersistentCollection $coll, $element) - { - throw new \BadMethodCallException("Removing an element is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function removeKey(PersistentCollection $coll, $key) - { - throw new \BadMethodCallException("Removing a key is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function get(PersistentCollection $coll, $index) - { - throw new \BadMethodCallException("Selecting a collection by index is not supported by this CollectionPersister."); - } - - /** - * {@inheritdoc} - */ - public function loadCriteria(PersistentCollection $coll, Criteria $criteria) - { - throw new \BadMethodCallException("Filtering a collection by Criteria is not supported by this CollectionPersister."); - } } diff --git a/lib/Doctrine/ORM/Persisters/CollectionPersister.php b/lib/Doctrine/ORM/Persisters/CollectionPersister.php index d2ad2e4da..855b85a30 100644 --- a/lib/Doctrine/ORM/Persisters/CollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/CollectionPersister.php @@ -100,16 +100,6 @@ interface CollectionPersister */ public function removeElement(PersistentCollection $collection, $element); - /** - * Removes an element by key. - * - * @param \Doctrine\ORM\PersistentCollection $collection - * @param mixed $key - * - * @return void - */ - public function removeKey(PersistentCollection $collection, $key); - /** * Gets an element by key. * diff --git a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php index 6ab3fc3d9..f671d8921 100644 --- a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -60,21 +60,26 @@ class ManyToManyPersister extends AbstractCollectionPersister return; // ignore inverse side } - $diff = $coll->getDeleteDiff(); - $sql = $this->getDeleteRowSQL($coll); + $insertSql = $this->getInsertRowSQL($coll); + $deleteSql = $this->getDeleteRowSQL($coll); - foreach ($diff as $element) { - $this->conn->executeUpdate($sql, $this->getDeleteRowSQLParameters($coll, $element)); + foreach ($coll->getDeleteDiff() as $element) { + $this->conn->executeUpdate($deleteSql, $this->getDeleteRowSQLParameters($coll, $element)); } - $diff = $coll->getInsertDiff(); - $sql = $this->getInsertRowSQL($coll); - - foreach ($diff as $element) { - $this->conn->executeUpdate($sql, $this->getInsertRowSQLParameters($coll, $element)); + foreach ($coll->getInsertDiff() as $element) { + $this->conn->executeUpdate($insertSql, $this->getInsertRowSQLParameters($coll, $element)); } } + /** + * {@inheritdoc} + */ + public function get(PersistentCollection $coll, $index) + { + throw new \BadMethodCallException("Selecting a collection by index is not supported by this CollectionPersister."); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php index 5586bd99a..5727111a1 100644 --- a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -214,4 +214,12 @@ class OneToManyPersister extends AbstractCollectionPersister return $persister->delete($element); } + + /** + * {@inheritdoc} + */ + public function loadCriteria(PersistentCollection $collection, Criteria $criteria) + { + throw new \BadMethodCallException("Filtering a collection by Criteria is not supported by this CollectionPersister."); + } }