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

code refactoring on BasicEntityPersister

This commit is contained in:
Fabio B. Silva 2012-07-24 22:33:23 -03:00
parent 7e348b7815
commit 308b54a8f3
4 changed files with 424 additions and 359 deletions

File diff suppressed because it is too large Load Diff

View File

@ -266,7 +266,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
/**
* {@inheritdoc}
*/
protected function getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null)
protected function getSelectSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null)
{
$idColumns = $this->class->getIdentifierColumnNames();
$baseTableAlias = $this->getSQLTableAlias($this->class->name);
@ -442,7 +442,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
/*
* Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly.
*/
protected function getSelectColumnListSQL()
protected function getSelectColumnsSQL()
{
throw new \BadMethodCallException("Illegal invocation of ".__METHOD__.".");
}

View File

@ -41,13 +41,13 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
}
/** {@inheritdoc} */
protected function getSelectColumnListSQL()
protected function getSelectColumnsSQL()
{
if ($this->selectColumnListSql !== null) {
return $this->selectColumnListSql;
}
$columnList = parent::getSelectColumnListSQL();
$columnList = parent::getSelectColumnsSQL();
$rootClass = $this->em->getClassMetadata($this->class->rootEntityName);
$tableAlias = $this->getSQLTableAlias($rootClass->name);
@ -92,7 +92,9 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
return $this->selectColumnListSql;
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function getInsertColumnList()
{
$columns = parent::getInsertColumnList();
@ -103,13 +105,17 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
return $columns;
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function getSQLTableAlias($className, $assocName = '')
{
return parent::getSQLTableAlias($this->class->rootEntityName, $assocName);
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function getSelectConditionSQL(array $criteria, $assoc = null)
{
$conditionSql = parent::getSelectConditionSQL($criteria, $assoc);
@ -121,7 +127,9 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL();
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function getSelectConditionCriteriaSQL(Criteria $criteria)
{
$conditionSql = parent::getSelectConditionCriteriaSQL($criteria);
@ -151,7 +159,9 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
. ' IN (' . implode(', ', $values) . ')';
}
/** {@inheritdoc} */
/**
* {@inheritdoc}
*/
protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
{
// Ensure that the filters are applied to the root entity of the inheritance tree

View File

@ -83,7 +83,7 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
public function testStripNonAlphanumericCharactersFromSelectColumnListSQL()
{
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\SimpleEntity'));
$method = new \ReflectionMethod($persister, 'getSelectColumnListSQL');
$method = new \ReflectionMethod($persister, 'getSelectColumnsSQL');
$method->setAccessible(true);
$this->assertEquals('t0."simple-entity-id" AS simpleentityid1, t0."simple-entity-value" AS simpleentityvalue2', $method->invoke($persister));