diff --git a/src/Controller/Component/DataTablesComponent.php b/src/Controller/Component/DataTablesComponent.php index 25adc6c..4871c0d 100644 --- a/src/Controller/Component/DataTablesComponent.php +++ b/src/Controller/Component/DataTablesComponent.php @@ -23,38 +23,38 @@ class DataTablesComponent extends Component CallbackTrait; protected $_defaultConfig = [ - 'start' => 0, - 'length' => 10, - 'order' => [], - 'search' => '', - 'prefixSearch' => true, // use "LIKE …%" instead of "LIKE %…%" conditions - 'conditionsOr' => [], // table-wide search conditions + 'start' => 0, + 'length' => 10, + 'order' => [], + 'search' => '', + 'prefixSearch' => true, // use "LIKE …%" instead of "LIKE %…%" conditions + 'conditionsOr' => [], // table-wide search conditions 'conditionsAnd' => [], // column search conditions - 'matching' => [], // column search conditions for foreign tables - 'comparison' => [], // per-column comparison definition + 'matching' => [], // column search conditions for foreign tables + 'comparison' => [], // per-column comparison definition ]; protected $_defaultComparison = [ - 'string' => 'LIKE', - 'text' => 'LIKE', - 'uuid' => 'LIKE', - 'integer' => '=', + 'string' => 'LIKE', + 'text' => 'LIKE', + 'uuid' => 'LIKE', + 'integer' => '=', 'biginteger' => '=', - 'float' => '=', - 'decimal' => '=', - 'boolean' => '=', - 'binary' => 'LIKE', - 'date' => 'LIKE', - 'datetime' => 'LIKE', - 'timestamp' => 'LIKE', - 'time' => 'LIKE', - 'json' => 'LIKE', + 'float' => '=', + 'decimal' => '=', + 'boolean' => '=', + 'binary' => 'LIKE', + 'date' => 'LIKE', + 'datetime' => 'LIKE', + 'timestamp' => 'LIKE', + 'time' => 'LIKE', + 'json' => 'LIKE', ]; protected $_viewVars = [ - 'recordsTotal' => 0, + 'recordsTotal' => 0, 'recordsFiltered' => 0, - 'draw' => 0, + 'draw' => 0, ]; /** @var \Cake\ORM\Table */ @@ -96,8 +96,7 @@ public function columns() * * @return Query to be evaluated (Query::count() may have already been called) */ - public function find(string $tableName, string $finder = 'all', array $options = [], array $columns = []) - : Query + public function find(string $tableName, string $finder = 'all', array $options = [], array $columns = []): Query { $delegateSearch = $options['delegateSearch'] ?? false; if (empty($columns)) @@ -224,8 +223,7 @@ private function _order(array &$options, &$columns) * * @return bool : true if additional filtering takes place */ - private function _filter(array &$options, &$columns) - : bool + private function _filter(array &$options, &$columns): bool { $queryParams = $this->getController()->getRequest()->getQueryParams(); @@ -358,8 +356,7 @@ private function _addCondition($column, $value, $type = 'and') * * @return string : Database comparison operator */ - protected function _getComparison($table, string $column) - : string + protected function _getComparison($table, string $column): string { $config = new Collection($this->getConfig('comparison')); @@ -381,8 +378,9 @@ protected function _getComparison($table, string $column) private function _setViewVars() { $controller = $this->getController(); + $view = $controller->createView(); - $_serialize = $controller->viewVars['_serialize'] ?? []; + $_serialize = $view->get('_serialize', []); $_serialize = array_merge($_serialize, array_keys($this->_viewVars)); $controller->set($this->_viewVars); diff --git a/src/Lib/ColumnDefinition.php b/src/Lib/ColumnDefinition.php index 40fda3a..30b5531 100644 --- a/src/Lib/ColumnDefinition.php +++ b/src/Lib/ColumnDefinition.php @@ -52,8 +52,7 @@ public function __construct(array $template, ColumnDefinitions $owner) * * @return \DataTables\Lib\ColumnDefinition */ - public function add(...$args) - : ColumnDefinition + public function add(...$args): ColumnDefinition { return $this->owner->add(...$args); } @@ -66,8 +65,7 @@ public function add(...$args) * * @return ColumnDefinition */ - public function set($key, $value = null) - : ColumnDefinition + public function set($key, $value = null): ColumnDefinition { if (is_array($key)) { if (!empty($value)) @@ -88,8 +86,7 @@ public function set($key, $value = null) * * @return \DataTables\Lib\ColumnDefinition */ - public function __call($name, $arguments) - : ColumnDefinition + public function __call($name, $arguments): ColumnDefinition { if (in_array($name, $this->switchesPositive)) { if (!empty($arguments)) @@ -113,8 +110,7 @@ public function __call($name, $arguments) * * @return \DataTables\Lib\ColumnDefinition */ - public function unset(string $key) - : ColumnDefinition + public function unset(string $key): ColumnDefinition { unset($this->content[$key]); @@ -127,8 +123,7 @@ public function unset(string $key) * * @return ColumnDefinition */ - public function render(string $name, array $args = []) - : ColumnDefinition + public function render(string $name, array $args = []): ColumnDefinition { $this->content['render'] = new CallbackFunction($name, $args); @@ -138,8 +133,7 @@ public function render(string $name, array $args = []) /** * @return array */ - public function jsonSerialize() - : array + public function jsonSerialize(): array { return $this->content; } diff --git a/src/Lib/ColumnDefinitions.php b/src/Lib/ColumnDefinitions.php index 88fe185..97e7cdb 100644 --- a/src/Lib/ColumnDefinitions.php +++ b/src/Lib/ColumnDefinitions.php @@ -21,8 +21,7 @@ class ColumnDefinitions implements \JsonSerializable, \ArrayAccess, \IteratorAgg * * @return ColumnDefinition */ - public function add($column, string $fieldName = null) - : ColumnDefinition + public function add($column, string $fieldName = null): ColumnDefinition { if (!is_array($column)) $column = [ @@ -72,8 +71,7 @@ public function setTitles(array $titles) * * @return array: column definitions */ - public function jsonSerialize() - : array + public function jsonSerialize(): array { return array_values($this->columns); } @@ -83,8 +81,7 @@ public function jsonSerialize() * * @return bool */ - public function offsetExists($offset) - : bool + public function offsetExists($offset): bool { if (is_numeric($offset)) return isset($this->columns[$offset]); diff --git a/src/View/Helper/DataTablesHelper.php b/src/View/Helper/DataTablesHelper.php index 3c6515f..9bb4af2 100644 --- a/src/View/Helper/DataTablesHelper.php +++ b/src/View/Helper/DataTablesHelper.php @@ -22,9 +22,9 @@ class DataTablesHelper extends Helper public $helpers = ['Html', 'Url']; protected $_defaultConfig = [ - 'searching' => true, - 'processing' => true, - 'serverSide' => true, + 'searching' => true, + 'processing' => true, + 'serverSide' => true, 'deferRender' => true, ]; @@ -33,8 +33,7 @@ class DataTablesHelper extends Helper * * @return string */ - public function renderTableUtility(TableUtility $tableUtility) - : string + public function renderTableUtility(TableUtility $tableUtility): string { return $this->table($tableUtility->getTable(), $tableUtility->getOptions(), $tableUtility->getClass()); } @@ -48,15 +47,14 @@ public function renderTableUtility(TableUtility $tableUtility) * * @return string containing a and a