1
0
mirror of synced 2024-12-13 14:56:01 +03:00

remove '_' prefix at AbstractCollectionPersister

This commit is contained in:
Fabio B. Silva 2012-07-22 15:26:00 -03:00
parent b998a522b0
commit e6f08f0b92
5 changed files with 205 additions and 141 deletions

View File

@ -33,17 +33,17 @@ abstract class AbstractCollectionPersister
/**
* @var EntityManager
*/
protected $_em;
protected $em;
/**
* @var \Doctrine\DBAL\Connection
*/
protected $_conn;
protected $conn;
/**
* @var \Doctrine\ORM\UnitOfWork
*/
protected $_uow;
protected $uow;
/**
* The database platform.
@ -66,17 +66,17 @@ abstract class AbstractCollectionPersister
*/
public function __construct(EntityManager $em)
{
$this->_em = $em;
$this->_uow = $em->getUnitOfWork();
$this->_conn = $em->getConnection();
$this->platform = $this->_conn->getDatabasePlatform();
$this->em = $em;
$this->uow = $em->getUnitOfWork();
$this->conn = $em->getConnection();
$this->platform = $this->conn->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
}
/**
* Deletes the persistent state represented by the given collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
public function delete(PersistentCollection $coll)
{
@ -86,30 +86,30 @@ abstract class AbstractCollectionPersister
return; // ignore inverse side
}
$sql = $this->_getDeleteSQL($coll);
$this->_conn->executeUpdate($sql, $this->_getDeleteSQLParameters($coll));
$sql = $this->getDeleteSQL($coll);
$this->conn->executeUpdate($sql, $this->getDeleteSQLParameters($coll));
}
/**
* Gets the SQL statement for deleting the given collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
abstract protected function _getDeleteSQL(PersistentCollection $coll);
abstract protected function getDeleteSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete
* the given collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
abstract protected function _getDeleteSQLParameters(PersistentCollection $coll);
abstract protected function getDeleteSQLParameters(PersistentCollection $coll);
/**
* Updates the given collection, synchronizing it's state with the database
* by inserting, updating and deleting individual elements.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
public function update(PersistentCollection $coll)
{
@ -120,63 +120,117 @@ abstract class AbstractCollectionPersister
}
$this->deleteRows($coll);
//$this->updateRows($coll);
$this->insertRows($coll);
}
/**
* Delete rows
*
* @param \Doctrine\ORM\PersistentCollection $coll
*/
public function deleteRows(PersistentCollection $coll)
{
$deleteDiff = $coll->getDeleteDiff();
$sql = $this->_getDeleteRowSQL($coll);
$diff = $coll->getDeleteDiff();
$sql = $this->getDeleteRowSQL($coll);
foreach ($deleteDiff as $element) {
$this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
foreach ($diff as $element) {
$this->conn->executeUpdate($sql, $this->getDeleteRowSQLParameters($coll, $element));
}
}
//public function updateRows(PersistentCollection $coll)
//{}
/**
* Insert rows
*
* @param \Doctrine\ORM\PersistentCollection $coll
*/
public function insertRows(PersistentCollection $coll)
{
$insertDiff = $coll->getInsertDiff();
$sql = $this->_getInsertRowSQL($coll);
$diff = $coll->getInsertDiff();
$sql = $this->getInsertRowSQL($coll);
foreach ($insertDiff as $element) {
$this->_conn->executeUpdate($sql, $this->_getInsertRowSQLParameters($coll, $element));
foreach ($diff as $element) {
$this->conn->executeUpdate($sql, $this->getInsertRowSQLParameters($coll, $element));
}
}
/**
* Count the size of this persistent collection
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @return integer
*/
public function count(PersistentCollection $coll)
{
throw new \BadMethodCallException("Counting the size of this persistent collection is not supported by this CollectionPersister.");
}
/**
* Slice elements
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param integer $offset
* @param integer $length
* @return array
*/
public function slice(PersistentCollection $coll, $offset, $length = null)
{
throw new \BadMethodCallException("Slicing elements is not supported by this CollectionPersister.");
}
/**
* Check for existance of an element
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed \Doctrine\ORM\PersistentCollection
* @return boolean
*/
public function contains(PersistentCollection $coll, $element)
{
throw new \BadMethodCallException("Checking for existance of an element is not supported by this CollectionPersister.");
}
/**
* Check for existance of a key
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed $key
* @return boolean
*/
public function containsKey(PersistentCollection $coll, $key)
{
throw new \BadMethodCallException("Checking for existance of a key is not supported by this CollectionPersister.");
}
/**
* Remove an element
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return mixed
*/
public function removeElement(PersistentCollection $coll, $element)
{
throw new \BadMethodCallException("Removing an element is not supported by this CollectionPersister.");
}
/**
* Remove an element by key
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed $key
*/
public function removeKey(PersistentCollection $coll, $key)
{
throw new \BadMethodCallException("Removing a key is not supported by this CollectionPersister.");
}
/**
* Get an element by key
*
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed $index
* @return object
*/
public function get(PersistentCollection $coll, $index)
{
throw new \BadMethodCallException("Selecting a collection by index is not supported by this CollectionPersister.");
@ -185,39 +239,39 @@ abstract class AbstractCollectionPersister
/**
* Gets the SQL statement used for deleting a row from the collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
abstract protected function _getDeleteRowSQL(PersistentCollection $coll);
abstract protected function getDeleteRowSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to delete the given
* element from the given collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed $element
*/
abstract protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element);
abstract protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element);
/**
* Gets the SQL statement used for updating a row in the collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
abstract protected function _getUpdateRowSQL(PersistentCollection $coll);
abstract protected function getUpdateRowSQL(PersistentCollection $coll);
/**
* Gets the SQL statement used for inserting a row in the collection.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
*/
abstract protected function _getInsertRowSQL(PersistentCollection $coll);
abstract protected function getInsertRowSQL(PersistentCollection $coll);
/**
* Gets the SQL parameters for the corresponding SQL statement to insert the given
* element of the given collection into the database.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param mixed $element
*/
abstract protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element);
abstract protected function getInsertRowSQLParameters(PersistentCollection $coll, $element);
}

View File

@ -338,7 +338,7 @@ class BasicEntityPersister
*
* Subclasses are also supposed to take care of versioning when overriding this method,
* if necessary. The {@link updateTable} method can be used to apply the data retrieved
* from {@_prepareUpdateData} on the target tables, thereby optionally applying versioning.
* from {@prepareUpdateData} on the target tables, thereby optionally applying versioning.
*
* @param object $entity The entity to update.
*/

View File

@ -439,13 +439,17 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
return 'FROM ' .$this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' . $baseTableAlias . $joinSql;
}
/* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */
/*
* Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly.
*/
protected function getSelectColumnListSQL()
{
throw new \BadMethodCallException("Illegal invocation of ".__METHOD__.".");
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function getInsertColumnList()
{
// Identifier columns must always come first in the column list of subclasses.

View File

@ -38,11 +38,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
*
* @override
*/
protected function _getDeleteRowSQL(PersistentCollection $coll)
protected function getDeleteRowSQL(PersistentCollection $coll)
{
$columns = array();
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$class = $this->em->getClassMetadata(get_class($coll->getOwner()));
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
$columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
@ -60,34 +60,34 @@ class ManyToManyPersister extends AbstractCollectionPersister
* {@inheritdoc}
*
* @override
* @internal Order of the parameters must be the same as the order of the columns in
* _getDeleteRowSql.
* @internal Order of the parameters must be the same as the order of the columns in getDeleteRowSql.
*/
protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element)
protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element)
{
return $this->_collectJoinTableColumnParameters($coll, $element);
return $this->collectJoinTableColumnParameters($coll, $element);
}
/**
* {@inheritdoc}
*
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function getUpdateRowSQL(PersistentCollection $coll)
{
throw new \BadMethodCallException("Insert Row SQL is not used for ManyToManyPersister");
}
/**
* {@inheritdoc}
*
* @override
* @internal Order of the parameters must be the same as the order of the columns in getInsertRowSql.
*/
protected function _getUpdateRowSQL(PersistentCollection $coll)
{}
/**
* {@inheritdoc}
*
* @override
* @internal Order of the parameters must be the same as the order of the columns in
* _getInsertRowSql.
*/
protected function _getInsertRowSQL(PersistentCollection $coll)
protected function getInsertRowSQL(PersistentCollection $coll)
{
$columns = array();
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$class = $this->em->getClassMetadata(get_class($coll->getOwner()));
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
@ -106,33 +106,32 @@ class ManyToManyPersister extends AbstractCollectionPersister
* {@inheritdoc}
*
* @override
* @internal Order of the parameters must be the same as the order of the columns in
* _getInsertRowSql.
* @internal Order of the parameters must be the same as the order of the columns in getInsertRowSql.
*/
protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element)
protected function getInsertRowSQLParameters(PersistentCollection $coll, $element)
{
return $this->_collectJoinTableColumnParameters($coll, $element);
return $this->collectJoinTableColumnParameters($coll, $element);
}
/**
* Collects the parameters for inserting/deleting on the join table in the order
* of the join table columns as specified in ManyToManyMapping#joinTableColumns.
*
* @param $coll
* @param $element
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return array
*/
private function _collectJoinTableColumnParameters(PersistentCollection $coll, $element)
private function collectJoinTableColumnParameters(PersistentCollection $coll, $element)
{
$params = array();
$mapping = $coll->getMapping();
$isComposite = count($mapping['joinTableColumns']) > 2;
$identifier1 = $this->_uow->getEntityIdentifier($coll->getOwner());
$identifier2 = $this->_uow->getEntityIdentifier($element);
$identifier1 = $this->uow->getEntityIdentifier($coll->getOwner());
$identifier2 = $this->uow->getEntityIdentifier($element);
if ($isComposite) {
$class1 = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$class1 = $this->em->getClassMetadata(get_class($coll->getOwner()));
$class2 = $coll->getTypeClass();
}
@ -162,11 +161,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
*
* @override
*/
protected function _getDeleteSQL(PersistentCollection $coll)
protected function getDeleteSQL(PersistentCollection $coll)
{
$columns = array();
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$class = $this->em->getClassMetadata(get_class($coll->getOwner()));
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform);
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
@ -181,12 +180,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
* {@inheritdoc}
*
* @override
* @internal Order of the parameters must be the same as the order of the columns in
* _getDeleteSql.
* @internal Order of the parameters must be the same as the order of the columns in getDeleteSql.
*/
protected function _getDeleteSQLParameters(PersistentCollection $coll)
protected function getDeleteSQLParameters(PersistentCollection $coll)
{
$identifier = $this->_uow->getEntityIdentifier($coll->getOwner());
$identifier = $this->uow->getEntityIdentifier($coll->getOwner());
$mapping = $coll->getMapping();
$params = array();
@ -198,7 +196,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
}
// Composite identifier
$sourceClass = $this->_em->getClassMetadata(get_class($coll->getOwner()));
$sourceClass = $this->em->getClassMetadata(get_class($coll->getOwner()));
foreach ($mapping['relationToSourceKeyColumns'] as $srcColumn) {
$params[] = $identifier[$sourceClass->fieldNames[$srcColumn]];
@ -216,11 +214,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
$params = array();
$mapping = $coll->getMapping();
$association = $mapping;
$class = $this->_em->getClassMetadata($mapping['sourceEntity']);
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
$class = $this->em->getClassMetadata($mapping['sourceEntity']);
$id = $this->em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
if ( ! $mapping['isOwningSide']) {
$targetEntity = $this->_em->getClassMetadata($mapping['targetEntity']);
$targetEntity = $this->em->getClassMetadata($mapping['targetEntity']);
$association = $targetEntity->associationMappings[$mapping['mappedBy']];
}
@ -249,11 +247,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
. $joinTargetEntitySQL
. ' WHERE ' . implode(' AND ', $conditions);
return $this->_conn->fetchColumn($sql, $params);
return $this->conn->fetchColumn($sql, $params);
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param int $offset
* @param int $length
* @return array
@ -262,17 +260,17 @@ class ManyToManyPersister extends AbstractCollectionPersister
{
$mapping = $coll->getMapping();
return $this->_em->getUnitOfWork()->getEntityPersister($mapping['targetEntity'])->getManyToManyCollection($mapping, $coll->getOwner(), $offset, $length);
return $this->em->getUnitOfWork()->getEntityPersister($mapping['targetEntity'])->getManyToManyCollection($mapping, $coll->getOwner(), $offset, $length);
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return boolean
*/
public function contains(PersistentCollection $coll, $element)
{
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
// Shortcut for new entities
$entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW);
@ -290,17 +288,17 @@ class ManyToManyPersister extends AbstractCollectionPersister
$sql = 'SELECT 1 FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses);
return (bool) $this->_conn->fetchColumn($sql, $params);
return (bool) $this->conn->fetchColumn($sql, $params);
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return boolean
*/
public function removeElement(PersistentCollection $coll, $element)
{
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
// shortcut for new entities
$entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW);
@ -319,7 +317,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$sql = 'DELETE FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses);
return (bool) $this->_conn->executeUpdate($sql, $params);
return (bool) $this->conn->executeUpdate($sql, $params);
}
/**
@ -330,19 +328,19 @@ class ManyToManyPersister extends AbstractCollectionPersister
*/
private function getJoinTableRestrictions(PersistentCollection $coll, $element, $addFilters)
{
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
$mapping = $filterMapping = $coll->getMapping();
if ( ! $mapping['isOwningSide']) {
$sourceClass = $this->_em->getClassMetadata($mapping['targetEntity']);
$targetClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
$sourceClass = $this->em->getClassMetadata($mapping['targetEntity']);
$targetClass = $this->em->getClassMetadata($mapping['sourceEntity']);
$sourceId = $uow->getEntityIdentifier($element);
$targetId = $uow->getEntityIdentifier($coll->getOwner());
$mapping = $sourceClass->associationMappings[$mapping['mappedBy']];
} else {
$sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
$targetClass = $this->_em->getClassMetadata($mapping['targetEntity']);
$sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
$sourceId = $uow->getEntityIdentifier($coll->getOwner());
$targetId = $uow->getEntityIdentifier($element);
}
@ -393,7 +391,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
*/
public function getFilterSql($mapping)
{
$targetClass = $this->_em->getClassMetadata($mapping['targetEntity']);
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
if ($mapping['isOwningSide']) {
$joinColumns = $mapping['relationToTargetKeyColumns'];
@ -402,7 +400,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
$joinColumns = $mapping['relationToSourceKeyColumns'];
}
$targetClass = $this->_em->getClassMetadata($targetClass->rootEntityName);
$targetClass = $this->em->getClassMetadata($targetClass->rootEntityName);
// A join is needed if there is filtering on the target entity
$joinTargetEntitySQL = '';
@ -434,7 +432,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
{
$filterClauses = array();
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
$filterClauses[] = '(' . $filterExpr . ')';
}

View File

@ -36,14 +36,14 @@ class OneToManyPersister extends AbstractCollectionPersister
* Generates the SQL UPDATE that updates a particular row's foreign
* key to null.
*
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @return string
* @override
*/
protected function _getDeleteRowSQL(PersistentCollection $coll)
protected function getDeleteRowSQL(PersistentCollection $coll)
{
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata($mapping['targetEntity']);
$class = $this->em->getClassMetadata($mapping['targetEntity']);
return 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform)
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
@ -51,52 +51,60 @@ class OneToManyPersister extends AbstractCollectionPersister
/**
* {@inheritdoc}
*
*/
protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element)
protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element)
{
return array_values($this->_uow->getEntityIdentifier($element));
}
protected function _getInsertRowSQL(PersistentCollection $coll)
{
return "UPDATE xxx SET foreign_key = yyy WHERE foreign_key = zzz";
return array_values($this->uow->getEntityIdentifier($element));
}
/**
* Gets the SQL parameters for the corresponding SQL statement to insert the given
* element of the given collection into the database.
*
* @param PersistentCollection $coll
* @param mixed $element
* {@inheritdoc}
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element)
{}
/* Not used for OneToManyPersister */
protected function _getUpdateRowSQL(PersistentCollection $coll)
protected function getInsertRowSQL(PersistentCollection $coll)
{
return;
throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister");
}
/**
* Generates the SQL UPDATE that updates all the foreign keys to null.
*
* @param PersistentCollection $coll
* {@inheritdoc}
*
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function _getDeleteSQL(PersistentCollection $coll)
protected function getInsertRowSQLParameters(PersistentCollection $coll, $element)
{
throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister");
}
/**
* Gets the SQL parameters for the corresponding SQL statement to delete
* the given collection.
* {@inheritdoc}
*
* @param PersistentCollection $coll
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function _getDeleteSQLParameters(PersistentCollection $coll)
{}
protected function getUpdateRowSQL(PersistentCollection $coll)
{
throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister");
}
/**
* {@inheritdoc}
*
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function getDeleteSQL(PersistentCollection $coll)
{
throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister");
}
/**
* {@inheritdoc}
*
* @throws \BadMethodCallException Not used for OneToManyPersister
*/
protected function getDeleteSQLParameters(PersistentCollection $coll)
{
throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister");
}
/**
* {@inheritdoc}
@ -104,9 +112,9 @@ class OneToManyPersister extends AbstractCollectionPersister
public function count(PersistentCollection $coll)
{
$mapping = $coll->getMapping();
$targetClass = $this->_em->getClassMetadata($mapping['targetEntity']);
$sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
$targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
$sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
$id = $this->em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
$whereClauses = array();
$params = array();
@ -119,8 +127,8 @@ class OneToManyPersister extends AbstractCollectionPersister
: $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]];
}
$filterTargetClass = $this->_em->getClassMetadata($targetClass->rootEntityName);
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
$filterTargetClass = $this->em->getClassMetadata($targetClass->rootEntityName);
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ($filterExpr = $filter->addFilterConstraint($filterTargetClass, 't')) {
$whereClauses[] = '(' . $filterExpr . ')';
}
@ -130,11 +138,11 @@ class OneToManyPersister extends AbstractCollectionPersister
. ' FROM ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' t'
. ' WHERE ' . implode(' AND ', $whereClauses);
return $this->_conn->fetchColumn($sql, $params);
return $this->conn->fetchColumn($sql, $params);
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param int $offset
* @param int $length
* @return \Doctrine\Common\Collections\ArrayCollection
@ -142,21 +150,21 @@ class OneToManyPersister extends AbstractCollectionPersister
public function slice(PersistentCollection $coll, $offset, $length = null)
{
$mapping = $coll->getMapping();
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
$persister = $uow->getEntityPersister($mapping['targetEntity']);
return $persister->getOneToManyCollection($mapping, $coll->getOwner(), $offset, $length);
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return boolean
*/
public function contains(PersistentCollection $coll, $element)
{
$mapping = $coll->getMapping();
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
// shortcut for new entities
$entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW);
@ -181,13 +189,13 @@ class OneToManyPersister extends AbstractCollectionPersister
}
/**
* @param PersistentCollection $coll
* @param \Doctrine\ORM\PersistentCollection $coll
* @param object $element
* @return boolean
*/
public function removeElement(PersistentCollection $coll, $element)
{
$uow = $this->_em->getUnitOfWork();
$uow = $this->em->getUnitOfWork();
// shortcut for new entities
$entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW);
@ -203,10 +211,10 @@ class OneToManyPersister extends AbstractCollectionPersister
}
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata($mapping['targetEntity']);
$class = $this->em->getClassMetadata($mapping['targetEntity']);
$sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform)
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
return (bool) $this->conn->executeUpdate($sql, $this->getDeleteRowSQLParameters($coll, $element));
}
}