1
0
mirror of synced 2025-01-30 20:11:49 +03:00

[DDC-551] Fixed CS, comments by @stof

This commit is contained in:
Alexander 2011-12-05 23:00:52 +01:00
parent f4663f4512
commit efe7a01482
9 changed files with 50 additions and 48 deletions

View File

@ -804,7 +804,7 @@ class EntityManager implements ObjectManager
*/
public function getFilters()
{
if(null === $this->filterCollection) {
if (null === $this->filterCollection) {
$this->filterCollection = new FilterCollection($this);
}
@ -814,7 +814,7 @@ class EntityManager implements ObjectManager
/**
* Checks whether the state of the filter collection is clean.
*
* @return boolean True, iff the filter collection is clean.
* @return boolean True, if the filter collection is clean.
*/
public function isFiltersStateClean()
{
@ -825,7 +825,7 @@ class EntityManager implements ObjectManager
/**
* Checks whether the Entity Manager has filters.
*
* @return True, iff the EM has a filter collection.
* @return True, if the EM has a filter collection.
*/
public function hasFilters()
{

View File

@ -903,8 +903,11 @@ class BasicEntityPersister
$alias = $this->_getSQLTableAlias($this->_class->name);
if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) {
if($conditionSql) $conditionSql .= ' AND ';
if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) {
if ($conditionSql) {
$conditionSql .= ' AND ';
}
$conditionSql .= $filterSql;
}
@ -1033,7 +1036,7 @@ class BasicEntityPersister
}
// Add filter SQL
if('' !== $filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) {
if ('' !== $filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) {
$this->_selectJoinSql .= ' AND ' . $filterSql;
}
} else {
@ -1541,7 +1544,7 @@ class BasicEntityPersister
. $this->getLockTablesSql($alias)
. ' WHERE ' . $this->_getSelectConditionSQL($criteria);
if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) {
if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) {
$sql .= ' AND ' . $filterSql;
}
@ -1559,8 +1562,8 @@ class BasicEntityPersister
protected function getJoinSQLForJoinColumns($joinColumns)
{
// if one of the join columns is nullable, return left join
foreach($joinColumns as $joinColumn) {
if(isset($joinColumn['nullable']) && $joinColumn['nullable']){
foreach ($joinColumns as $joinColumn) {
if (isset($joinColumn['nullable']) && $joinColumn['nullable']) {
return 'LEFT JOIN';
}
}
@ -1595,8 +1598,8 @@ class BasicEntityPersister
{
$filterClauses = array();
foreach($this->_em->getFilters()->getEnabledFilters() as $filter) {
if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
$filterClauses[] = '(' . $filterExpr . ')';
}
}

View File

@ -329,9 +329,9 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$joinSql .= $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn;
if($parentClass->name === $this->_class->rootEntityName) {
if ($parentClass->name === $this->_class->rootEntityName) {
// Add filters on the root class
if('' !== $filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) {
if ('' !== $filterSql = $this->generateFilterConditionSQL($parentClass, $tableAlias)) {
$joinSql .= ' AND ' . $filterSql;
}
}
@ -383,9 +383,12 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$conditionSql = $this->_getSelectConditionSQL($criteria, $assoc);
// If the current class in the root entity, add the filters
if($this->_class->name === $this->_class->rootEntityName) {
if('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $baseTableAlias)) {
if($conditionSql) $conditionSql .= ' AND ';
if ($this->_class->name === $this->_class->rootEntityName) {
if ('' !== $filterSql = $this->generateFilterConditionSQL($this->_class, $baseTableAlias)) {
if ($conditionSql) {
$conditionSql .= ' AND ';
}
$conditionSql .= $filterSql;
}
}

View File

@ -219,7 +219,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
}
list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($mapping);
if('' !== $filterSql) {
if ('' !== $filterSql) {
$whereClauses[] = $filterSql;
}
@ -331,9 +331,9 @@ class ManyToManyPersister extends AbstractCollectionPersister
: $sourceId[$sourceClass->fieldNames[$mapping['relationToSourceKeyColumns'][$joinTableColumn]]];
}
if($addFilters) {
if ($addFilters) {
list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($mapping);
if('' !== $filterSql) {
if ('' !== $filterSql) {
$quotedJoinTable .= ' t ' . $joinTargetEntitySQL;
$whereClauses[] = $filterSql;
}
@ -355,13 +355,13 @@ class ManyToManyPersister extends AbstractCollectionPersister
// A join is needed if there is filtering on the target entity
$joinTargetEntitySQL = '';
if('' !== $filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
if ('' !== $filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
$joinTargetEntitySQL = ' JOIN '
. $targetClass->getQuotedTableName($this->_conn->getDatabasePlatform()) . ' te'
. ' ON';
$joinTargetEntitySQLClauses = array();
foreach($mapping['relationToTargetKeyColumns'] as $joinTableColumn => $targetTableColumn) {
foreach ($mapping['relationToTargetKeyColumns'] as $joinTableColumn => $targetTableColumn) {
$joinTargetEntitySQLClauses[] = ' t.' . $joinTableColumn . ' = ' . 'te.' . $targetTableColumn;
}
@ -383,8 +383,8 @@ class ManyToManyPersister extends AbstractCollectionPersister
{
$filterClauses = array();
foreach($this->_em->getFilters()->getEnabledFilters() as $filter) {
if('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
$filterClauses[] = '(' . $filterExpr . ')';
}
}

View File

@ -121,8 +121,8 @@ class OneToManyPersister extends AbstractCollectionPersister
: $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]];
}
foreach($this->_em->getFilters()->getEnabledFilters() as $filter) {
if("" !== $filterExpr = $filter->addFilterConstraint($targetClass, 't')) {
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetClass, 't')) {
$whereClauses[] = '(' . $filterExpr . ')';
}
}

View File

@ -138,7 +138,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
{
// Ensure that the filters are applied to the root entity of the inheritance tree
$realTargetEntity = $targetEntity;
if($targetEntity->name !== $targetEntity->rootEntityName) {
if ($targetEntity->name !== $targetEntity->rootEntityName) {
$realTargetEntity = $this->_em->getClassMetadata($targetEntity->rootEntityName);
}

View File

@ -49,7 +49,6 @@ abstract class SQLFilter
* Constructs the SQLFilter object.
*
* @param EntityManager $em The EM
* @final
*/
final public function __construct(EntityManager $em)
{
@ -63,7 +62,6 @@ abstract class SQLFilter
* @param string $value Value of the parameter.
* @param string $type Type of the parameter.
*
* @final
* @return SQLFilter The current SQL filter.
*/
final public function setParameter($name, $value, $type)
@ -88,12 +86,11 @@ abstract class SQLFilter
*
* @param string $name Name of the parameter.
*
* @final
* @return string The SQL escaped parameter to use in a query.
*/
final public function getParameter($name)
{
if(!isset($this->parameters[$name])) {
if (!isset($this->parameters[$name])) {
throw new \InvalidArgumentException("Parameter '" . $name . "' does not exist.");
}
@ -103,8 +100,7 @@ abstract class SQLFilter
/**
* Returns as string representation of the SQLFilter parameters (the state).
*
* @final
* @return string String representation of the the SQLFilter.
* @return string String representation of the SQLFilter.
*/
final public function __toString()
{

View File

@ -103,11 +103,11 @@ class FilterCollection
*/
public function enable($name)
{
if(null === $filterClass = $this->config->getFilterClassName($name)) {
if (null === $filterClass = $this->config->getFilterClassName($name)) {
throw new \InvalidArgumentException("Filter '" . $name . "' does not exist.");
}
if(!isset($this->enabledFilters[$name])) {
if (!isset($this->enabledFilters[$name])) {
$this->enabledFilters[$name] = new $filterClass($this->em);
// Keep the enabled filters sorted for the hash
@ -153,7 +153,7 @@ class FilterCollection
*/
public function getFilter($name)
{
if(!isset($this->enabledFilters[$name])) {
if (!isset($this->enabledFilters[$name])) {
throw new \InvalidArgumentException("Filter '" . $name . "' is not enabled.");
}
@ -176,12 +176,12 @@ class FilterCollection
public function getHash()
{
// If there are only clean filters, the previous hash can be returned
if(self::FILTERS_STATE_CLEAN === $this->filtersState) {
if (self::FILTERS_STATE_CLEAN === $this->filtersState) {
return $this->filterHash;
}
$filterHash = '';
foreach($this->enabledFilters as $name => $filter) {
foreach ($this->enabledFilters as $name => $filter) {
$filterHash .= $name . $filter;
}

View File

@ -365,9 +365,9 @@ class SqlWalker implements TreeWalker
{
$filterClauses = array();
if($this->_em->hasFilters()) {
foreach($this->_em->getFilters()->getEnabledFilters() as $filter) {
if("" !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
if ($this->_em->hasFilters()) {
foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) {
$filterClauses[] = '(' . $filterExpr . ')';
}
}
@ -827,9 +827,8 @@ class SqlWalker implements TreeWalker
}
// Apply the filters
if("" !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
if ( ! $first) $sql .= ' AND '; else $first = false;
$sql .= $filterExpr;
if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
$sql .= ' AND ' . $filterExpr;
}
} else if ($assoc['type'] == ClassMetadata::MANY_TO_MANY) {
// Join relation table
@ -896,9 +895,8 @@ class SqlWalker implements TreeWalker
}
// Apply the filters
if("" !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
if ( ! $first) $sql .= ' AND '; else $first = false;
$sql .= $filterExpr;
if ('' !== $filterExpr = $this->generateFilterConditionSQL($targetClass, $targetTableAlias)) {
$sql .= ' AND ' . $filterExpr;
}
}
@ -1508,13 +1506,15 @@ class SqlWalker implements TreeWalker
$class = $this->_queryComponents[$dqlAlias]['metadata'];
$tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
if("" !== $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) {
if ('' !== $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias)) {
$filterClauses[] = $filterExpr;
}
}
if (count($filterClauses)) {
if($condSql) $condSql .= ' AND ';
if ($condSql) {
$condSql .= ' AND ';
}
$condSql .= implode(' AND ', $filterClauses);
}