Skip to content

Commit

Permalink
Merge pull request #1004 from APY/update_doctrine26
Browse files Browse the repository at this point in the history
  • Loading branch information
DonCallisto authored Mar 31, 2018
2 parents 3722231 + bf2aa22 commit 2b0eab7
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions Grid/Source/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

class Entity extends Source
{
const DOT_DQL_ALIAS_PH = '__dot__';
const COLON_DQL_ALIAS_PH = '__col__';

/**
* @var \Doctrine\ORM\EntityManager
*/
Expand Down Expand Up @@ -213,7 +216,7 @@ protected function getFieldName($column, $withAlias = false)
}
}

$alias = str_replace('.', '::', $column->getId());
$alias = $this->fromColIdToAlias($column->getId());
} elseif (strpos($name, ':') !== false) {
$previousParent = $this->getTableAlias();
$alias = $name;
Expand Down Expand Up @@ -253,6 +256,16 @@ protected function getFieldName($column, $withAlias = false)
return $name;
}

/**
* @param string $colId
*
* @return string
*/
private function fromColIdToAlias($colId)
{
return str_replace(['.', ':'], [self::DOT_DQL_ALIAS_PH, self::COLON_DQL_ALIAS_PH], $colId);
}

/**
* @param string $fieldName
*
Expand Down Expand Up @@ -536,7 +549,7 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
$row = new Row();

foreach ($item as $key => $value) {
$key = str_replace('::', '.', $key);
$key = $this->fromAliasToColId($key);

if (in_array($key, $serializeColumns) && is_string($value)) {
$value = unserialize($value);
Expand All @@ -559,6 +572,16 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
return $result;
}

/**
* @param string $alias
*
* @return string
*/
private function fromAliasToColId($alias)
{
return str_replace([self::DOT_DQL_ALIAS_PH, self::COLON_DQL_ALIAS_PH], ['.', ':'], $alias);
}

public function getTotalCount($maxResults = null)
{
// Doctrine Bug Workaround: http://www.doctrine-project.org/jira/browse/DDC-1927
Expand Down Expand Up @@ -702,7 +725,9 @@ public function populateSelectFilters($columns, $loop = false)

$values = [];
foreach ($result as $row) {
$value = $row[str_replace('.', '::', $column->getId())];
$alias = $this->fromColIdToAlias($column->getId());

$value = $row[$alias];

switch ($column->getType()) {
case 'array':
Expand Down

0 comments on commit 2b0eab7

Please sign in to comment.