Some small improvements to persisters.
This commit is contained in:
parent
dd883f2136
commit
96955d6e79
@ -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.");
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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}
|
||||
*/
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user