Skip to content

Commit 2b0eab7

Browse files
authored
Merge pull request #1004 from APY/update_doctrine26
Fix #772, #1000, #1001
2 parents 3722231 + bf2aa22 commit 2b0eab7

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

Grid/Source/Entity.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
class Entity extends Source
3030
{
31+
const DOT_DQL_ALIAS_PH = '__dot__';
32+
const COLON_DQL_ALIAS_PH = '__col__';
33+
3134
/**
3235
* @var \Doctrine\ORM\EntityManager
3336
*/
@@ -213,7 +216,7 @@ protected function getFieldName($column, $withAlias = false)
213216
}
214217
}
215218

216-
$alias = str_replace('.', '::', $column->getId());
219+
$alias = $this->fromColIdToAlias($column->getId());
217220
} elseif (strpos($name, ':') !== false) {
218221
$previousParent = $this->getTableAlias();
219222
$alias = $name;
@@ -253,6 +256,16 @@ protected function getFieldName($column, $withAlias = false)
253256
return $name;
254257
}
255258

259+
/**
260+
* @param string $colId
261+
*
262+
* @return string
263+
*/
264+
private function fromColIdToAlias($colId)
265+
{
266+
return str_replace(['.', ':'], [self::DOT_DQL_ALIAS_PH, self::COLON_DQL_ALIAS_PH], $colId);
267+
}
268+
256269
/**
257270
* @param string $fieldName
258271
*
@@ -536,7 +549,7 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
536549
$row = new Row();
537550

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

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

575+
/**
576+
* @param string $alias
577+
*
578+
* @return string
579+
*/
580+
private function fromAliasToColId($alias)
581+
{
582+
return str_replace([self::DOT_DQL_ALIAS_PH, self::COLON_DQL_ALIAS_PH], ['.', ':'], $alias);
583+
}
584+
562585
public function getTotalCount($maxResults = null)
563586
{
564587
// Doctrine Bug Workaround: http://www.doctrine-project.org/jira/browse/DDC-1927
@@ -702,7 +725,9 @@ public function populateSelectFilters($columns, $loop = false)
702725

703726
$values = [];
704727
foreach ($result as $row) {
705-
$value = $row[str_replace('.', '::', $column->getId())];
728+
$alias = $this->fromColIdToAlias($column->getId());
729+
730+
$value = $row[$alias];
706731

707732
switch ($column->getType()) {
708733
case 'array':

0 commit comments

Comments
 (0)