From 2b6aeaa654bb6e52282eec97950a56072d3c32f1 Mon Sep 17 00:00:00 2001 From: Philippe MILINK Date: Tue, 23 Oct 2018 17:29:02 +0200 Subject: [PATCH] Add attributes mapped, is_association and data_source * allow to create column not mapped, and not defined with DQL * allow to use data from another column and transform it * add documentation --- Datatable/Column/AbstractColumn.php | 203 +++++++++++++++++++++++++- Datatable/Column/ActionColumn.php | 6 +- Datatable/Column/AttributeColumn.php | 204 +++++++++++++++++++++++++++ Datatable/Column/BooleanColumn.php | 8 +- Datatable/Column/Column.php | 8 +- Datatable/Column/ColumnInterface.php | 6 +- Datatable/Column/DateTimeColumn.php | 8 +- Datatable/Column/ImageColumn.php | 10 +- Datatable/Column/NumberColumn.php | 8 +- Resources/doc/columns.md | 3 + Response/DatatableFormatter.php | 12 +- Response/DatatableQueryBuilder.php | 100 ++++++------- 12 files changed, 496 insertions(+), 80 deletions(-) create mode 100644 Datatable/Column/AttributeColumn.php diff --git a/Datatable/Column/AbstractColumn.php b/Datatable/Column/AbstractColumn.php index 7da35c1c..d2ccae39 100644 --- a/Datatable/Column/AbstractColumn.php +++ b/Datatable/Column/AbstractColumn.php @@ -290,6 +290,47 @@ abstract class AbstractColumn implements ColumnInterface */ protected $originalTypeOfField; + /** + * If the field is sent in the response, to show in the webpage + * Is set in the ColumnBuilder. + * Default: true + * + * @var bool + */ + protected $sentInResponse; + + /** + * If this column displays the total of its cells in its head + * Default: false + * + * @var bool + */ + protected $computeTotal; + + /** + * Contains the eventually computed total of the column + * + * @var mixed + */ + protected $total; + + /** + * If the column represents a real column in the database + * + * @var bool + */ + protected $mapped; + + /** + * Force the association property + */ + protected $isAssociation; + + /** + * The source of data, if different from title and no dql specified + */ + protected $dataSource; + //------------------------------------------------- // Options //------------------------------------------------- @@ -323,6 +364,11 @@ public function configureOptions(OptionsResolver $resolver) 'join_type' => 'leftJoin', 'type_of_field' => null, 'responsive_priority' => null, + 'sent_in_response' => true, + 'compute_total' => false, + 'mapped' => true, + 'is_association' => false, + 'data_source' => null )); $resolver->setAllowedTypes('cell_type', array('null', 'string')); @@ -343,6 +389,11 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('join_type', 'string'); $resolver->setAllowedTypes('type_of_field', array('null', 'string')); $resolver->setAllowedTypes('responsive_priority', array('null', 'int')); + $resolver->setAllowedTypes('sent_in_response', array('bool')); + $resolver->setAllowedTypes('compute_total', array('bool')); + $resolver->setAllowedTypes('mapped', array('bool')); + $resolver->setAllowedTypes('is_association', array('bool')); + $resolver->setAllowedTypes('data_source', array('string', 'null')); $resolver->setAllowedValues('cell_type', array(null, 'th', 'td')); $resolver->setAllowedValues('join_type', array(null, 'join', 'leftJoin', 'innerJoin')); @@ -388,6 +439,10 @@ public function isAssociation() */ public function isToManyAssociation() { + if ($this->isAssociation) { + return true; + } + if (true === $this->isAssociation() && null !== $this->typeOfAssociation) { if (in_array(ClassMetadataInfo::ONE_TO_MANY, $this->typeOfAssociation) || in_array(ClassMetadataInfo::MANY_TO_MANY, $this->typeOfAssociation)) { return true; @@ -426,9 +481,9 @@ public function addDataToOutputArray(array &$row) /** * {@inheritdoc} */ - public function renderCellContent(array &$row) + public function renderCellContent(array &$row, array &$resultRow) { - $this->isToManyAssociation() ? $this->renderToMany($row) : $this->renderSingleField($row); + $this->isToManyAssociation() ? $this->renderToMany($row, $resultRow) : $this->renderSingleField($row, $resultRow); } /** @@ -1075,4 +1130,148 @@ public function setOriginalTypeOfField($originalTypeOfField) return $this; } + + /** + * Get sentInResponse. + * + * @return bool + */ + public function getSentInResponse() + { + return $this->sentInResponse; + } + + /** + * Set sentIntResponse. + * + * @param bool $sentInResponse + * + * @return $this + */ + public function setSentInResponse($sentInResponse) + { + $this->sentInResponse = $sentInResponse; + + return $this; + } + + /** + * Get computeTotal. + * + * @return bool + */ + public function getComputeTotal() + { + return $this->computeTotal; + } + + /** + * Set sentIntResponse. + * + * @param bool $computeTotal + * + * @return $this + */ + public function setComputeTotal($computeTotal) + { + $this->computeTotal = $computeTotal; + + return $this; + } + + /** + * Get total + * + * @return mixed + */ + public function getTotal() + { + return $this->total; + } + + /** + * Set total + * + * @param $total + * + * @return $this + */ + public function setTotal($total) + { + $this->total = $total; + + return $this; + } + + /** + * Get mapped + * + * @return bool + */ + public function getMapped() + { + return $this->mapped; + } + + /** + * Set mapped + * + * @param bool $mapped + * + * @return $this + */ + public function setMapped($mapped) + { + $this->mapped = $mapped; + + return $this; + } + + /** + * Get isAssociation + * + * @return bool + */ + public function getIsAssociation() + { + return $this->isAssociation; + } + + /** + * Set isAssociation + * + * @param bool $isAssociation + * + * @return $this + */ + public function setIsAssociation($isAssociation) + { + $this->isAssociation = $isAssociation; + + return $this; + } + + /** + * Get data source + * + * @return null|string + */ + public function getDataSource() + { + return $this->isAssociation; + } + + /** + * Set data source + * + * @param null|string $dataSource + * + * @return $this + */ + public function setDataSource($dataSource) + { + $this->dataSource = $dataSource; + + return $this; + } } diff --git a/Datatable/Column/ActionColumn.php b/Datatable/Column/ActionColumn.php index 27d32ae3..506642cf 100644 --- a/Datatable/Column/ActionColumn.php +++ b/Datatable/Column/ActionColumn.php @@ -78,7 +78,7 @@ public function addDataToOutputArray(array &$row) /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $parameters = array(); $attributes = array(); @@ -138,7 +138,7 @@ public function renderSingleField(array &$row) } } - $row[$this->getIndex()] = $this->twig->render( + $resultRow[$this->getIndex()] = $this->twig->render( $this->getCellContentTemplate(), array( 'actions' => $this->actions, @@ -155,7 +155,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { throw new Exception('ActionColumn::renderToMany(): This function should never be called.'); } diff --git a/Datatable/Column/AttributeColumn.php b/Datatable/Column/AttributeColumn.php new file mode 100644 index 00000000..f19e02dd --- /dev/null +++ b/Datatable/Column/AttributeColumn.php @@ -0,0 +1,204 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sg\DatatablesBundle\Datatable\Column; + +use Sg\DatatablesBundle\Datatable\Helper; +use Sg\DatatablesBundle\Datatable\Filter\TextFilter; + +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Class AttributeColumn + * + * @package Sg\DatatablesBundle\Datatable\Column + */ +class AttributeColumn extends AbstractColumn +{ + /** + * The AttributeColumn is filterable. + */ + use FilterableTrait; + + /** + * The Attributes container. + * A required option. + * + * @var Closure + */ + protected $attributes; + + //------------------------------------------------- + // ColumnInterface + //------------------------------------------------- + + /** + * {@inheritdoc} + */ + public function renderSingleField(array &$row, array &$resultRow) + { + $renderAttributes = array(); + + $renderAttributes = call_user_func($this->attributes, $row); + + $path = Helper::getDataPropertyPath($this->data); + + $content = $this->twig->render( + $this->getCellContentTemplate(), + array( + 'attributes' => $renderAttributes, + 'data' => $this->accessor->getValue($row, $path) + ) + ); + + $this->accessor->setValue($resultRow, $path, $content); + + } + + /** + * {@inheritdoc} + */ + public function renderToMany(array &$row, array &$resultRow) + { + $value = null; + $path = Helper::getDataPropertyPath($this->data, $value); + + if ($this->accessor->isReadable($row, $path)) { + + if ($this->isEditableContentRequired($row)) { + // e.g. comments[ ].createdBy.username + // => $path = [comments] + // => $value = [createdBy][username] + + $entries = $this->accessor->getValue($row, $path); + + if (count($entries) > 0) { + foreach ($entries as $key => $entry) { + $currentPath = $path . '[' . $key . ']' . $value; + $currentObjectPath = Helper::getPropertyPathObjectNotation($path, $key, $value); + + $content = $this->renderTemplate( + $this->accessor->getValue($row, $currentPath), + $row[$this->editable->getPk()], + $currentObjectPath + ); + + $this->accessor->setValue($resultRow, $currentPath, $content); + } + } else { + // no placeholder - leave this blank + } + } + + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCellContentTemplate() + { + return '@SgDatatables/render/attributeColumn.html.twig'; + } + + /** + * {@inheritdoc} + */ + public function renderPostCreateDatatableJsContent() + { + return null; + } + + /** + * {@inheritdoc} + */ + public function getColumnType() + { + return parent::ACTION_COLUMN; + } + + //------------------------------------------------- + // Options + //------------------------------------------------- + + /** + * Config options. + * + * @param OptionsResolver $resolver + * + * @return $this + */ + public function configureOptions(OptionsResolver $resolver) + { + parent::configureOptions($resolver); + + $resolver->setDefaults(array( + 'filter' => array(TextFilter::class, array()), + 'attributes' => null, + )); + + $resolver->setAllowedTypes('filter', 'array'); + $resolver->setAllowedTypes('attributes', array('null', 'array', 'Closure')); + + return $this; + } + + //------------------------------------------------- + // Helper + //------------------------------------------------- + + /** + * Render template. + * + * @param string|null $data + * @param string $pk + * @param string|null $path + * + * @return mixed|string + */ + private function renderTemplate($data) + { + return $this->twig->render( + $this->getCellContentTemplate(), + array( + 'data' => $data, + ) + ); + } + + + /** + * Get attributes. + * + * @return Attributes[] + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Set attributes. + * + * @param Closure $attributes + * + * @return $this + * @throws Exception + */ + public function setAttributes($attributes) + { + $this->attributes = $attributes; + + return $this; + } +} diff --git a/Datatable/Column/BooleanColumn.php b/Datatable/Column/BooleanColumn.php index d9f25aae..a8a48767 100644 --- a/Datatable/Column/BooleanColumn.php +++ b/Datatable/Column/BooleanColumn.php @@ -84,7 +84,7 @@ class BooleanColumn extends AbstractColumn /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $path = Helper::getDataPropertyPath($this->data); @@ -96,7 +96,7 @@ public function renderSingleField(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $path)); } - $this->accessor->setValue($row, $path, $content); + $this->accessor->setValue($resultRow, $path, $content); } @@ -106,7 +106,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { $value = null; $path = Helper::getDataPropertyPath($this->data, $value); @@ -130,7 +130,7 @@ public function renderToMany(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $currentPath)); } - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } else { // no placeholder - leave this blank diff --git a/Datatable/Column/Column.php b/Datatable/Column/Column.php index 8baa0fb8..8326ee50 100644 --- a/Datatable/Column/Column.php +++ b/Datatable/Column/Column.php @@ -41,7 +41,7 @@ class Column extends AbstractColumn /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $path = Helper::getDataPropertyPath($this->data); @@ -49,7 +49,7 @@ public function renderSingleField(array &$row) if ($this->isEditableContentRequired($row)) { $content = $this->renderTemplate($this->accessor->getValue($row, $path), $row[$this->editable->getPk()]); - $this->accessor->setValue($row, $path, $content); + $this->accessor->setValue($resultRow, $path, $content); } } @@ -60,7 +60,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { $value = null; $path = Helper::getDataPropertyPath($this->data, $value); @@ -85,7 +85,7 @@ public function renderToMany(array &$row) $currentObjectPath ); - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } else { // no placeholder - leave this blank diff --git a/Datatable/Column/ColumnInterface.php b/Datatable/Column/ColumnInterface.php index 95b97ad8..eea49cb5 100644 --- a/Datatable/Column/ColumnInterface.php +++ b/Datatable/Column/ColumnInterface.php @@ -86,7 +86,7 @@ public function addDataToOutputArray(array &$row); * * @return mixed */ - public function renderCellContent(array &$row); + public function renderCellContent(array &$row, array &$resultRow); /** * Render single field. @@ -95,7 +95,7 @@ public function renderCellContent(array &$row); * * @return $this */ - public function renderSingleField(array &$row); + public function renderSingleField(array &$row, array &$resultRow); /** * Render toMany. @@ -104,7 +104,7 @@ public function renderSingleField(array &$row); * * @return $this */ - public function renderToMany(array &$row); + public function renderToMany(array &$row, array &$resultRow); /** * Get the template for the 'renderCellContent' function. diff --git a/Datatable/Column/DateTimeColumn.php b/Datatable/Column/DateTimeColumn.php index e8d37d90..1a7a1256 100644 --- a/Datatable/Column/DateTimeColumn.php +++ b/Datatable/Column/DateTimeColumn.php @@ -60,7 +60,7 @@ class DateTimeColumn extends AbstractColumn /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $path = Helper::getDataPropertyPath($this->data); @@ -72,7 +72,7 @@ public function renderSingleField(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $path)); } - $this->accessor->setValue($row, $path, $content); + $this->accessor->setValue($resultRow, $path, $content); } @@ -82,7 +82,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { $value = null; $path = Helper::getDataPropertyPath($this->data, $value); @@ -106,7 +106,7 @@ public function renderToMany(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $currentPath)); } - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } else { // no placeholder - leave this blank diff --git a/Datatable/Column/ImageColumn.php b/Datatable/Column/ImageColumn.php index 7e693626..6f1f1048 100644 --- a/Datatable/Column/ImageColumn.php +++ b/Datatable/Column/ImageColumn.php @@ -100,7 +100,7 @@ class ImageColumn extends AbstractColumn /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $path = Helper::getDataPropertyPath($this->data); @@ -108,7 +108,7 @@ public function renderSingleField(array &$row) $content = $this->renderImageTemplate($this->accessor->getValue($row, $path), '-image'); - $this->accessor->setValue($row, $path, $content); + $this->accessor->setValue($resultRow, $path, $content); } @@ -118,7 +118,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { // e.g. images[ ].fileName // => $path = [images] @@ -134,13 +134,13 @@ public function renderToMany(array &$row) foreach ($images as $key => $image) { $currentPath = $path . '[' . $key . ']' . $value; $content = $this->renderImageTemplate($this->accessor->getValue($row, $currentPath), '-gallery-image'); - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } else { // create an entry for the placeholder image $currentPath = $path . '[0]' . $value; $content = $this->renderImageTemplate(null, '-gallery-image'); - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } diff --git a/Datatable/Column/NumberColumn.php b/Datatable/Column/NumberColumn.php index 25ce6154..fe1001da 100644 --- a/Datatable/Column/NumberColumn.php +++ b/Datatable/Column/NumberColumn.php @@ -53,7 +53,7 @@ class NumberColumn extends Column /** * {@inheritdoc} */ - public function renderSingleField(array &$row) + public function renderSingleField(array &$row, array &$resultRow) { $path = Helper::getDataPropertyPath($this->data); @@ -65,7 +65,7 @@ public function renderSingleField(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $path)); } - $this->accessor->setValue($row, $path, $content); + $this->accessor->setValue($resultRow, $path, $content); } @@ -75,7 +75,7 @@ public function renderSingleField(array &$row) /** * {@inheritdoc} */ - public function renderToMany(array &$row) + public function renderToMany(array &$row, array &$resultRow) { $value = null; $path = Helper::getDataPropertyPath($this->data, $value); @@ -99,7 +99,7 @@ public function renderToMany(array &$row) $content = $this->renderTemplate($this->accessor->getValue($row, $currentPath)); } - $this->accessor->setValue($row, $currentPath, $content); + $this->accessor->setValue($resultRow, $currentPath, $content); } } else { // no placeholder - leave this blank diff --git a/Resources/doc/columns.md b/Resources/doc/columns.md index 10578300..60734b3d 100644 --- a/Resources/doc/columns.md +++ b/Resources/doc/columns.md @@ -47,6 +47,9 @@ With 'null' initialized options uses the default value of the DataTables plugin. | responsive_priority | null or int | null | | Set column's visibility priority. Requires the Responsive extension. | | filter | array | TextFilter | | A Filter instance for individual filtering. | | editable | array or null | null | | An Editable instance for in-place editing. | +| mapped | bool | true | | Allow to create columns not mapped in entity neither defined by DQL. | +| is_association | bool | false | | Allow to force if the column is an association, usally used with `mapped` and `data_source`. | +| data_source | null or string | null | | Specify the column source of the data to manipulate in the current column. Usally used with `mapped` and `data_source`. | ### Example diff --git a/Response/DatatableFormatter.php b/Response/DatatableFormatter.php index 6d72f0b2..f85c6d52 100644 --- a/Response/DatatableFormatter.php +++ b/Response/DatatableFormatter.php @@ -113,15 +113,23 @@ public function runFormatter(Paginator $paginator, DatatableInterface $datatable $row = call_user_func($datatable->getLineFormatter(), $row); } + $resultRow = $row; + /** @var ColumnInterface $column */ foreach ($columns as $column) { // 3. Add some special data to the output array. For example, the visibility of actions. $column->addDataToOutputArray($row); // 4. Call Columns renderContent method to format row items (e.g. for images or boolean values) - $column->renderCellContent($row); + $column->renderCellContent($row, $resultRow); + } + + foreach ($columns as $column) { + if (!$column->getSentInResponse()) { + unset($resultRow[$column->getDql()]); + } } - $this->output['data'][] = $row; + $this->output['data'][] = $resultRow; } } diff --git a/Response/DatatableQueryBuilder.php b/Response/DatatableQueryBuilder.php index ee2c5fca..8c10bfe2 100644 --- a/Response/DatatableQueryBuilder.php +++ b/Response/DatatableQueryBuilder.php @@ -242,60 +242,62 @@ private function initColumnArrays() $currentAlias = $currentPart; $metadata = $this->metadata; - if (true === $this->accessor->getValue($column, 'customDql')) { - $columnAlias = str_replace('.', '_', $data); - - // Select - $selectDql = preg_replace('/\{([\w]+)\}/', '$1', $dql); - $this->addSelectColumn(null, $selectDql.' '.$columnAlias); - // Order on alias column name - $this->addOrderColumn($column, null, $columnAlias); - // Fix subqueries alias duplication - $searchDql = preg_replace('/\{([\w]+)\}/', '$1_search', $dql); - $this->addSearchColumn($column, null, $searchDql); - } elseif (true === $this->accessor->getValue($column, 'selectColumn')) { - $parts = explode('.', $dql); - - while (count($parts) > 1) { - $previousPart = $currentPart; - $previousAlias = $currentAlias; - - $currentPart = array_shift($parts); - $currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart.'_').$currentPart; - - if (!array_key_exists($previousAlias.'.'.$currentPart, $this->joins)) { - $this->addJoin($previousAlias.'.'.$currentPart, $currentAlias, $this->accessor->getValue($column, 'joinType')); + if ($this->accessor->getValue($column, 'mapped')) { + if (true === $this->accessor->getValue($column, 'customDql')) { + $columnAlias = str_replace('.', '_', $data); + + // Select + $selectDql = preg_replace('/\{([\w]+)\}/', '$1', $dql); + $this->addSelectColumn(null, $selectDql.' '.$columnAlias); + // Order on alias column name + $this->addOrderColumn($column, null, $columnAlias); + // Fix subqueries alias duplication + $searchDql = preg_replace('/\{([\w]+)\}/', '$1_search', $dql); + $this->addSearchColumn($column, null, $searchDql); + } elseif (true === $this->accessor->getValue($column, 'selectColumn')) { + $parts = explode('.', $dql); + + while (count($parts) > 1) { + $previousPart = $currentPart; + $previousAlias = $currentAlias; + + $currentPart = array_shift($parts); + $currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart.'_').$currentPart; + + if (!array_key_exists($previousAlias.'.'.$currentPart, $this->joins)) { + $this->addJoin($previousAlias.'.'.$currentPart, $currentAlias, $this->accessor->getValue($column, 'joinType')); + } + + $metadata = $this->setIdentifierFromAssociation($currentAlias, $currentPart, $metadata); } - $metadata = $this->setIdentifierFromAssociation($currentAlias, $currentPart, $metadata); - } - - $this->addSelectColumn($currentAlias, $this->getIdentifier($metadata)); - $this->addSelectColumn($currentAlias, $parts[0]); - $this->addSearchOrderColumn($column, $currentAlias, $parts[0]); - } else { - // Add Order-Field for VirtualColumn - if ($this->accessor->isReadable($column, 'orderColumn') && true === $this->accessor->getValue($column, 'orderable')) { - $orderColumn = $this->accessor->getValue($column, 'orderColumn'); - $orderParts = explode('.', $orderColumn); - if (count($orderParts) < 2) { - $orderColumn = $this->entityShortName.'.'.$orderColumn; - } - $this->orderColumns[] = $orderColumn; + $this->addSelectColumn($currentAlias, $this->getIdentifier($metadata)); + $this->addSelectColumn($currentAlias, $parts[0]); + $this->addSearchOrderColumn($column, $currentAlias, $parts[0]); } else { - $this->orderColumns[] = null; - } + // Add Order-Field for VirtualColumn + if ($this->accessor->isReadable($column, 'orderColumn') && true === $this->accessor->getValue($column, 'orderable')) { + $orderColumn = $this->accessor->getValue($column, 'orderColumn'); + $orderParts = explode('.', $orderColumn); + if (count($orderParts) < 2) { + $orderColumn = $this->entityShortName.'.'.$orderColumn; + } + $this->orderColumns[] = $orderColumn; + } else { + $this->orderColumns[] = null; + } - // Add Search-Field for VirtualColumn - if ($this->accessor->isReadable($column, 'searchColumn') && true === $this->accessor->getValue($column, 'searchable')) { - $searchColumn = $this->accessor->getValue($column, 'searchColumn'); - $searchParts = explode('.', $searchColumn); - if (count($searchParts) < 2) { - $searchColumn = $this->entityShortName.'.'.$searchColumn; + // Add Search-Field for VirtualColumn + if ($this->accessor->isReadable($column, 'searchColumn') && true === $this->accessor->getValue($column, 'searchable')) { + $searchColumn = $this->accessor->getValue($column, 'searchColumn'); + $searchParts = explode('.', $searchColumn); + if (count($searchParts) < 2) { + $searchColumn = $this->entityShortName.'.'.$searchColumn; + } + $this->searchColumns[] = $searchColumn; + } else { + $this->searchColumns[] = null; } - $this->searchColumns[] = $searchColumn; - } else { - $this->searchColumns[] = null; } } }