diff --git a/Grid/Source/Entity.php b/Grid/Source/Entity.php index 54700a58..6d5a606e 100644 --- a/Grid/Source/Entity.php +++ b/Grid/Source/Entity.php @@ -28,6 +28,9 @@ class Entity extends Source { + const DOT_DQL_ALIAS_PH = '__dot__'; + const COLON_DQL_ALIAS_PH = '__col__'; + /** * @var \Doctrine\ORM\EntityManager */ @@ -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; @@ -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 * @@ -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); @@ -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 @@ -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':