Exemplo n.º 1
0
 /**
  * Checks if the given column is a virtual relation and if so, generates and saves table aliases for it
  *
  * @param string $columnName
  */
 protected function addTableAliasesForVirtualRelation($columnName)
 {
     if (!empty($this->virtualColumnExpressions[$columnName])) {
         // already processed
         return;
     }
     $joinIds = $this->addTableAliasesForJoinIdentifiers($this->joinIdHelper->explodeColumnName($columnName));
     if (!$this->virtualRelationsJoins) {
         return;
     }
     $hasVirtualRelation = false;
     foreach ($joinIds as $columnJoinId) {
         $hasVirtualRelation = $hasVirtualRelation || array_search($columnJoinId, $this->virtualRelationsJoins);
     }
     if (!$hasVirtualRelation) {
         return;
     }
     $parentJoinId = $this->getParentJoinIdentifier($this->joinIdHelper->buildColumnJoinIdentifier($columnName));
     $fieldName = $this->getFieldName($parentJoinId);
     $className = $this->getEntityClassName($parentJoinId);
     if ($this->virtualRelationProvider->isVirtualRelation($className, $fieldName)) {
         $tableAlias = $this->aliases[$this->virtualRelationProvider->getTargetJoinAlias($className, $fieldName, $this->getFieldName($columnName))];
     } else {
         $joinId = end($joinIds);
         $tableAlias = $this->tableAliases[$joinId];
     }
     $this->virtualColumnExpressions[$columnName] = sprintf('%s.%s', $tableAlias, $this->getFieldName($columnName));
 }
Exemplo n.º 2
0
 /**
  * Generates and saves aliases for the given column and all its parent joins
  *
  * @param string $columnName String with specified format
  *                           rootEntityField+Class\Name::joinedEntityRelation+Relation\Class::fieldToSelect
  */
 protected function addTableAliasesForColumn($columnName)
 {
     /**
      * joinIds - array of joins with parent definition but without select field join definition(last one)
      *
      * For `rootEntityField+Class\Name::joinedEntityRelation+Relation\Class::fieldToSelect` column name will be
      *
      * - `Root\Class::rootEntityField`
      * - `Root\Class::rootEntityField+Class\Name::joinedEntityRelation`
      */
     $joinIds = $this->joinIdHelper->explodeColumnName($columnName);
     $this->addTableAliasesForJoinIdentifiers($joinIds);
     $this->addColumnAliasesForVirtualRelation($columnName, $joinIds);
     $this->addTableAliasesForVirtualColumn($columnName);
 }
Exemplo n.º 3
0
 /**
  * Generates and saves aliases for the given column and all its parent joins
  *
  * @param string $columnName
  */
 protected function addTableAliasesForColumn($columnName)
 {
     $this->addTableAliasesForJoinIdentifiers($this->joinIdHelper->explodeColumnName($columnName));
     $this->addTableAliasesForVirtualColumn($columnName);
 }
Exemplo n.º 4
0
 /**
  * @dataProvider explodeColumnNameProvider
  */
 public function testExplodeColumnName($columnName, $expected)
 {
     $this->assertEquals($expected, $this->helper->explodeColumnName($columnName));
 }