More deprecated code removal.
This commit is contained in:
parent
965cdbdbbb
commit
678f47f494
@ -70,55 +70,6 @@ class OneToManyPersister extends AbstractCollectionPersister
|
|||||||
return $persister->load(array($mapping['mappedBy'] => $coll->getOwner(), $mapping['indexBy'] => $index), null, null, array(), null, 1);
|
return $persister->load(array($mapping['mappedBy'] => $coll->getOwner(), $mapping['indexBy'] => $index), null, null, array(), null, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates the SQL UPDATE that updates a particular row's foreign
|
|
||||||
* key to null.
|
|
||||||
*
|
|
||||||
* @param \Doctrine\ORM\PersistentCollection $coll
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @override
|
|
||||||
*/
|
|
||||||
protected function getDeleteRowSQL(PersistentCollection $coll)
|
|
||||||
{
|
|
||||||
$mapping = $coll->getMapping();
|
|
||||||
$class = $this->em->getClassMetadata($mapping['targetEntity']);
|
|
||||||
$tableName = $this->quoteStrategy->getTableName($class, $this->platform);
|
|
||||||
$idColumns = $class->getIdentifierColumnNames();
|
|
||||||
|
|
||||||
return 'DELETE FROM ' . $tableName
|
|
||||||
. ' WHERE ' . implode('= ? AND ', $idColumns) . ' = ?';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element)
|
|
||||||
{
|
|
||||||
return array_values($this->uow->getEntityIdentifier($element));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException Not used for OneToManyPersister.
|
|
||||||
*/
|
|
||||||
protected function getInsertRowSQL(PersistentCollection $coll)
|
|
||||||
{
|
|
||||||
throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException Not used for OneToManyPersister.
|
|
||||||
*/
|
|
||||||
protected function getInsertRowSQLParameters(PersistentCollection $coll, $element)
|
|
||||||
{
|
|
||||||
throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -170,14 +121,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
public function contains(PersistentCollection $coll, $element)
|
public function contains(PersistentCollection $coll, $element)
|
||||||
{
|
{
|
||||||
$entityState = $this->uow->getEntityState($element, UnitOfWork::STATE_NEW);
|
if ( ! $this->isValidEntityState($element)) {
|
||||||
|
|
||||||
if ($entityState === UnitOfWork::STATE_NEW) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Entity is scheduled for inclusion
|
|
||||||
if ($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($element)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,15 +141,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
public function removeElement(PersistentCollection $coll, $element)
|
public function removeElement(PersistentCollection $coll, $element)
|
||||||
{
|
{
|
||||||
$entityState = $this->uow->getEntityState($element, UnitOfWork::STATE_NEW);
|
if ( ! $this->isValidEntityState($element)) {
|
||||||
|
|
||||||
if ($entityState === UnitOfWork::STATE_NEW) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If Entity is scheduled for inclusion, it is not in this collection.
|
|
||||||
// We can assure that because it would have return true before on array check
|
|
||||||
if ($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($element)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,4 +158,28 @@ class OneToManyPersister extends AbstractCollectionPersister
|
|||||||
{
|
{
|
||||||
throw new \BadMethodCallException("Filtering a collection by Criteria is not supported by this CollectionPersister.");
|
throw new \BadMethodCallException("Filtering a collection by Criteria is not supported by this CollectionPersister.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if entity is in a valid state for operations.
|
||||||
|
*
|
||||||
|
* @param $entity
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isValidEntityState($entity)
|
||||||
|
{
|
||||||
|
$entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW);
|
||||||
|
|
||||||
|
if ($entityState === UnitOfWork::STATE_NEW) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If Entity is scheduled for inclusion, it is not in this collection.
|
||||||
|
// We can assure that because it would have return true before on array check
|
||||||
|
if ($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user