From e8d30068e25e769a2c1bcf63c651def577fa541c Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 5 Dec 2011 22:05:42 +0100 Subject: [PATCH] [DDC-551] Various refactorings --- lib/Doctrine/ORM/Persisters/BasicEntityPersister.php | 9 ++++----- lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php | 1 + lib/Doctrine/ORM/Persisters/ManyToManyPersister.php | 9 ++++----- lib/Doctrine/ORM/Persisters/OneToManyPersister.php | 1 + lib/Doctrine/ORM/Persisters/SingleTablePersister.php | 1 + lib/Doctrine/ORM/Query/SqlWalker.php | 9 ++++----- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index ec725693f..c58c4c3bf 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -72,6 +72,7 @@ use PDO, * @author Roman Borschel * @author Giorgio Sironi * @author Benjamin Eberlei + * @author Alexander * @since 2.0 */ class BasicEntityPersister @@ -1592,16 +1593,14 @@ class BasicEntityPersister */ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { - $filterSql = ''; + $filterClauses = array(); - $first = true; foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { - if (!$first) $filterSql .= ' AND '; else $first = false; - $filterSql .= '(' . $filterExpr . ')'; + $filterClauses[] = '(' . $filterExpr . ')'; } } - return $filterSql; + return implode(' AND ', $filterClauses); } } diff --git a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php index daed5b01d..ad34f5c31 100644 --- a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php @@ -31,6 +31,7 @@ use Doctrine\ORM\ORMException, * * @author Roman Borschel * @author Benjamin Eberlei + * @author Alexander * @since 2.0 * @see http://martinfowler.com/eaaCatalog/classTableInheritance.html */ diff --git a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php index 41d7b24a9..f765b77f1 100644 --- a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -30,6 +30,7 @@ use Doctrine\ORM\Mapping\ClassMetadata, * * @author Roman Borschel * @author Guilherme Blanco + * @author Alexander * @since 2.0 */ class ManyToManyPersister extends AbstractCollectionPersister @@ -379,16 +380,14 @@ class ManyToManyPersister extends AbstractCollectionPersister */ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { - $filterSql = ''; + $filterClauses = array(); - $first = true; foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { - if($first) $first = false; else $filterSql .= ' AND '; - $filterSql .= '(' . $filterExpr . ')'; + $filterClauses[] = '(' . $filterExpr . ')'; } } - return $filterSql; + return implode(' AND ', $filterClauses); } } diff --git a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php index 0cc380337..17575aaac 100644 --- a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -29,6 +29,7 @@ use Doctrine\ORM\PersistentCollection, * * @author Roman Borschel * @author Guilherme Blanco + * @author Alexander * @since 2.0 */ class OneToManyPersister extends AbstractCollectionPersister diff --git a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php index d11486e93..cb005575f 100644 --- a/lib/Doctrine/ORM/Persisters/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/SingleTablePersister.php @@ -27,6 +27,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; * * @author Roman Borschel * @author Benjamin Eberlei + * @author Alexander * @since 2.0 * @link http://martinfowler.com/eaaCatalog/singleTableInheritance.html */ diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index e3d412df1..cf20f747b 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -33,6 +33,7 @@ use Doctrine\DBAL\LockMode, * @author Guilherme Blanco * @author Roman Borschel * @author Benjamin Eberlei + * @author Alexander * @since 2.0 * @todo Rename: SQLWalker */ @@ -362,19 +363,17 @@ class SqlWalker implements TreeWalker */ private function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { - $filterSql = ''; + $filterClauses = array(); if($this->_em->hasFilters()) { - $first = true; foreach($this->_em->getFilters()->getEnabledFilters() as $filter) { if("" !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { - if ( ! $first) $filterSql .= ' AND '; else $first = false; - $filterSql .= '(' . $filterExpr . ')'; + $filterClauses[] = '(' . $filterExpr . ')'; } } } - return $filterSql; + return implode(' AND ', $filterClauses); } /** * Walks down a SelectStatement AST node, thereby generating the appropriate SQL.