diff --git a/.docs/actions.md b/.docs/actions.md index 241bc17f..01c2da03 100644 --- a/.docs/actions.md +++ b/.docs/actions.md @@ -32,7 +32,7 @@ Parameters are the same as in ColumnLink: /** * $key, $name = '', $href = $key, array $params = NULL */ -$grid->addAction('edit', 'Edit'); +$datagrid->addAction('edit', 'Edit'); ``` ### Icon diff --git a/.docs/columns.md b/.docs/columns.md index fe40b157..d621abee 100644 --- a/.docs/columns.md +++ b/.docs/columns.md @@ -42,15 +42,15 @@ There are several column classes and they all have some common behaviour and pro Let's add a simple text column like we've done before: ```php -$grid->addColumnText('name', 'Name'); +$datagrid->addColumnText('name', 'Name'); ``` Parameters that the method takes are: `$key, $title, $column = $key`. By default, the column name is the same as the key. There is a key, because you can show more data grid columns that will display only one database table column: ```php -$grid->addColumnText('name', 'Name'); // Equivalent to $grid->addColumnText('name', 'Name', 'name'); -$grid->addColumnText('name2', 'Name', 'name'); -$grid->addColumnText('name3', 'Name', 'name'); +$datagrid->addColumnText('name', 'Name'); // Equivalent to $datagrid->addColumnText('name', 'Name', 'name'); +$datagrid->addColumnText('name2', 'Name', 'name'); +$datagrid->addColumnText('name3', 'Name', 'name'); ``` ### Templates @@ -58,7 +58,7 @@ $grid->addColumnText('name3', 'Name', 'name'); Columns may have it's own template. I will add one more parameter (optional) to the method `::setTemplate()`, just for fun: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setTemplate(__DIR__ . '/templates/name.latte', ['foo' => 'bar']); ``` @@ -70,7 +70,7 @@ In that template (name.latte), we will have two variables available: `$item` and We can also modify data outputting via renderer callbacks: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setRenderer(function($item) { return strtoupper($item->id . ': ' . $item->name); }); @@ -79,7 +79,7 @@ $grid->addColumnText('name', 'Name') But hey, what if I want to replace **just some** rows? No problem, the second optional argument tells me (callback again) whether the datagrid should use your renderer or not. Example: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setRenderer(function($item) { return strtoupper($item->id . ': ' . $item->name); }, function($item) { @@ -92,7 +92,7 @@ $grid->addColumnText('name', 'Name') Outputted data could have a simple array replacement instead of renderer callback: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setReplacement([ 'John' => 'Doe', 'Hell' => 'o' @@ -104,7 +104,7 @@ $grid->addColumnText('name', 'Name') By default, latte escapes all values from data source. You can disable that: ```php -$grid->addColumnText('link_html', 'Link') +$datagrid->addColumnText('link_html', 'Link') ->setTemplateEscaping(FALSE); ``` @@ -113,21 +113,21 @@ $grid->addColumnText('link_html', 'Link') You can set the column as sortable. ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setSortable(); ``` When using doctrine as data source, you can output data the object way using dot-notation and property accessor. But when you are using column of related table for sorting, you probably want to use alias for sorting: ```php -$grid->addColumnText('role', 'User role', 'role.name') +$datagrid->addColumnText('role', 'User role', 'role.name') ->setSortable('r.name') ``` ### Resetting pagination after sorting ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setSortable() ->setSortableResetPagination(); ``` diff --git a/.docs/data-source.md b/.docs/data-source.md index 7887299b..a03d8343 100644 --- a/.docs/data-source.md +++ b/.docs/data-source.md @@ -27,7 +27,7 @@ There are these supported datasources so far: You can set data source like this: ```php -$grid->setDataSource($this->ndb->table('user')); // NDBT +$datagrid->setDataSource($this->ndb->table('user')); // NDBT $grid->setDataSource($this->dibi->select('*')->from('user')); // Dibi $grid->setDataSource([['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Joe']]); // Array $grid->setDataSource($exampleRepository->createQueryBuilder('er')); // Doctrine query builder diff --git a/.docs/export.md b/.docs/export.md index ccdc9722..e9c77011 100644 --- a/.docs/export.md +++ b/.docs/export.md @@ -11,7 +11,7 @@ Table of contents ## ExportCallback -Datagrid allows you to export the data via `$grid->addExportCallback()`. The parameters are: +Datagrid allows you to export the data via `$datagrid->addExportCallback()`. The parameters are: ```php /** @@ -19,7 +19,7 @@ Datagrid allows you to export the data via `$grid->addExportCallback()`. The par * $callback = your export callback * $filtered = $should datagrid pass a filtered data to your callback, or all? */ -$grid->addExportCallback($text, $callback, $filtered = false); +$datagrid->addExportCallback($text, $callback, $filtered = false); ``` You can tell whether to use ajax or not (`->setAjax()`). Or a button title (`->setTitle('Title')`). Or target (`->setTarget('_blank')`). @@ -30,9 +30,9 @@ There is already a CSV export implemented (filtered and not filtered): ```php /** - * Or $grid->addExportCsvFiltered(); + * Or $datagrid->addExportCsvFiltered(); */ -$grid->addExportCsv('Csv export (filtered)', 'examples.csv') +$datagrid->addExportCsv('Csv export (filtered)', 'examples.csv') ->setTitle('Csv export (filtered)'); ``` @@ -45,13 +45,13 @@ ExportCsv ignores column template, because i don't like the idea Latte (templati When you're exporting the data, you can have different columns in export and in the datagrid. Or differently rendered. So there is another method `Contributte\Datagrid\Export\Export::setColumns()`. You can create instances of another columns and pass them in array to this method. These will be rendered in export: ```php -$column_name = new Contributte\Datagrid\Column\ColumnText($grid, 'name', 'name', 'Name'); -$column_even = (new Contributte\Datagrid\Column\ColumnText($grid, 'name', 'even', 'Even ID (yes/no)')) +$column_name = new Contributte\Datagrid\Column\ColumnText($datagrid, 'name', 'name', 'Name'); +$column_even = (new Contributte\Datagrid\Column\ColumnText($datagrid, 'name', 'even', 'Even ID (yes/no)')) ->setRenderer(function(array $item): string { return $item['id'] % 2 ? 'No' : 'Yes'; }); -$grid->addExportCsv('Csv export', 'examples_all.csv') +$datagrid->addExportCsv('Csv export', 'examples_all.csv') ->setTitle('Csv export') ->setColumns([ $column_name, @@ -69,10 +69,10 @@ By default, Datagrid exports data in `utf-8` with semicolon delimiter `;`. This * $output_encoding = 'utf-8' * $delimiter = ';' */ -$grid->addExportCsvFiltered('Csv export (filtered)', 'examples.csv'); +$datagrid->addExportCsvFiltered('Csv export (filtered)', 'examples.csv'); /** * Changed */ -$grid->addExportCsv( 'Csv export', 'examples_all.csv', 'windows-1250', ','); +$datagrid->addExportCsv( 'Csv export', 'examples_all.csv', 'windows-1250', ','); ``` diff --git a/.docs/filters.md b/.docs/filters.md index c14061ff..11561e37 100644 --- a/.docs/filters.md +++ b/.docs/filters.md @@ -30,14 +30,14 @@ Table of contents Either you can add filter to existing column by defining column and filter separately: ```php -$grid->addColumnText('name', 'Name'); -$grid->addFilterText('name', 'Name'); +$datagrid->addColumnText('name', 'Name'); +$datagrid->addFilterText('name', 'Name'); ``` Or you can add a filter directly to column definition: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setFilterText(); ``` @@ -47,7 +47,7 @@ There are several filter classes and they all have some common behaviour and pro /** * $key, $name, $columns */ -$grid->addFilterText('name', 'Name'); +$datagrid->addFilterText('name', 'Name'); /** * Equivalent diff --git a/.docs/group-action.md b/.docs/group-action.md index ff26feb7..c41f1a54 100644 --- a/.docs/group-action.md +++ b/.docs/group-action.md @@ -23,7 +23,7 @@ If you need to do some operations with multiple rows, there are group actions. T When you want to show just one action button, do simply that: ```php -$grid->addGroupButtonAction('Say hello')->onClick[] = [$this, 'sayHello']; +$datagrid->addGroupButtonAction('Say hello')->onClick[] = [$this, 'sayHello']; ``` ### One level @@ -31,8 +31,8 @@ $grid->addGroupButtonAction('Say hello')->onClick[] = [$this, 'sayHello']; ![Group action 1](https://github.com/contributte/datagrid/blob/master/.docs/assets/group_button_action_1.gif?raw=true) ```php -$grid->addGroupAction('Delete examples')->onSelect[] = [$this, 'deleteExamples']; -$grid->addGroupAction('Something else')->onSelect[] = [$this, 'doSomethingElse']; +$datagrid->addGroupAction('Delete examples')->onSelect[] = [$this, 'deleteExamples']; +$datagrid->addGroupAction('Something else')->onSelect[] = [$this, 'doSomethingElse']; ``` This will create one select box (['Delete examples', 'Something else']) and submit button. If you submit that form, your handler will be called. It will be called via ajax. diff --git a/.docs/index.md b/.docs/index.md index a9721d15..17c60c4c 100644 --- a/.docs/index.md +++ b/.docs/index.md @@ -72,10 +72,10 @@ class SimplePresenter extends BasePresenter public function createComponentSimpleGrid($name) { - $grid = new Datagrid($this, $name); + $datagrid = new Datagrid($this, $name); - $grid->setDataSource($this->db->select('*')->from('example')); - $grid->addColumnText('name', 'Name'); + $datagrid->setDataSource($this->db->select('*')->from('example')); + $datagrid->addColumnText('name', 'Name'); } } diff --git a/.docs/inline-add.md b/.docs/inline-add.md index 04c9c68d..043c77b6 100644 --- a/.docs/inline-add.md +++ b/.docs/inline-add.md @@ -8,7 +8,7 @@ Table of contents Since version `3.3.0` there is a feature "inline adding" available. Up above is a demo where you can try that out. Just hit the "plus" button, fill some inputs and save the container. Example implementation: ```php -$grid->addInlineAdd() +$datagrid->addInlineAdd() ->onControlAdd[] = function(Nette\Forms\Container $container) { $container->addText('id', '')->setAttribute('readonly'); $container->addText('name', ''); @@ -16,7 +16,7 @@ $grid->addInlineAdd() $container->addText('link', ''); }; -$grid->getInlineAdd()->onSubmit[] = function(Nette\Utils\ArrayHash $values): void { +$datagrid->getInlineAdd()->onSubmit[] = function(Nette\Utils\ArrayHash $values): void { $v = ''; foreach($values as $key => $value) { @@ -35,7 +35,7 @@ $grid->getInlineAdd()->onSubmit[] = function(Nette\Utils\ArrayHash $values): voi As you can see, new item row is rendered at the bottom of the table. You may change that and make datagrid render the new item row on the top: ```php -$grid->addInlineAdd() +$datagrid->addInlineAdd() ->setPositionTop(); // Or take it down again: ::setPositionTop(false) ``` @@ -44,8 +44,8 @@ $grid->addInlineAdd() When you use array datasource, there is one limitation. Simply redrawing the grid won't do. You will also have to set the datasource again to refresh the data. ```php -$grid->getInlineAdd()->onSubmit[] = function(ArrayHash $values) use ($grid): void { - $grid->setDatasource($this->model->getDatasource()); +$datagrid->getInlineAdd()->onSubmit[] = function(ArrayHash $values) use ($datagrid): void { + $datagrid->setDatasource($this->model->getDatasource()); $this->redrawControl(); }; ``` diff --git a/.docs/inline-edit.md b/.docs/inline-edit.md index 7b384559..c9f9fee8 100644 --- a/.docs/inline-edit.md +++ b/.docs/inline-edit.md @@ -20,7 +20,7 @@ As you can see in the example above (or on the homepage), there is column name a /** * Example callback */ -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setSortable() ->setEditableCallback(function($id, $value): void { echo("Id: $id, new value: $value"); die; @@ -29,7 +29,7 @@ $grid->addColumnText('name', 'Name') /** * Or you can do that properly */ -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setEditableCallback([$this, 'columnNameEdited']); ``` @@ -38,7 +38,7 @@ $grid->addColumnText('name', 'Name') Small inline edit is not limited to textarea, you can you input of type of your choice (that input will be submitted with either **blur** or **submit** (enter press) event). Example usage: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setEditableCallback(/**...*/) ->setEditableInputType('text', ['class' => 'form-control']); ``` @@ -46,7 +46,7 @@ $grid->addColumnText('name', 'Name') Or you can use a select: ```php -$grid->addColumnText('name', 'Name') +$datagrid->addColumnText('name', 'Name') ->setEditableCallback(/**...*/) ->setEditableInputTypeSelect([ 0 => 'Offline', @@ -63,7 +63,7 @@ $grid->addColumnText('name', 'Name') As you can see in the demo above, you can edit the link column but actually, only the link text will be edited. That you can achieve by following code: ```php -$grid->addColumnLink('link', 'Link', 'this#demo', 'name', ['id']) +$datagrid->addColumnLink('link', 'Link', 'this#demo', 'name', ['id']) ->setEditableValueCallback(function(Dibi\Row $row): string { return $row->name; }) @@ -87,12 +87,12 @@ Example useage: /** * @var Contributte\Datagrid\Datagrid */ -$grid = new Datagrid($this, $name); +$datagrid = new Datagrid($this, $name); /** * Big inline editing */ -$grid->addInlineEdit() +$datagrid->addInlineEdit() ->onControlAdd[] = function(Nette\Forms\Container $container): void { $container->addText('id', ''); $container->addText('name', ''); @@ -100,7 +100,7 @@ $grid->addInlineEdit() $container->addText('link', ''); }; -$grid->getInlineEdit()->onSetDefaults[] = function(Nette\Forms\Container $container, $item): void { +$datagrid->getInlineEdit()->onSetDefaults[] = function(Nette\Forms\Container $container, $item): void { $container->setDefaults([ 'id' => $item->id, 'name' => $item->name, diff --git a/.docs/localization.md b/.docs/localization.md index e6f7ecaf..737814c7 100644 --- a/.docs/localization.md +++ b/.docs/localization.md @@ -10,18 +10,18 @@ As you can see in the example below, a `SimpleTranslator` class comes with datag ```php public function createComponentLocalizationGrid($name): Contributte\Datagrid\Datagrid { - $grid = new Datagrid($this, $name); + $datagrid = new Datagrid($this, $name); - $grid->setDataSource($this->ndb->table('example')); + $datagrid->setDataSource($this->ndb->table('example')); - $grid->addColumnNumber('id', 'Id') + $datagrid->addColumnNumber('id', 'Id') ->setAlign('start') ->setSortable(); - $grid->addColumnText('name', 'Name') + $datagrid->addColumnText('name', 'Name') ->setSortable(); - $grid->addColumnDateTime('inserted', 'Inserted'); + $datagrid->addColumnDateTime('inserted', 'Inserted'); $translator = new Contributte\Datagrid\Localization\SimpleTranslator([ 'contributte_datagrid.no_item_found_reset' => 'Žádné položky nenalezeny. Filtr můžete vynulovat', @@ -44,7 +44,7 @@ public function createComponentLocalizationGrid($name): Contributte\Datagrid\Dat 'Inserted' => 'Vloženo' ]); - $grid->setTranslator($translator); + $datagrid->setTranslator($translator); } ``` @@ -55,7 +55,7 @@ All filters and their placeholders are translated normally except for `FilterSel You can change that behaviour: ```php -$grid->addFilterMultiSelect('status', 'Status:', [ +$datagrid->addFilterMultiSelect('status', 'Status:', [ 0 => 'Offline', 1 => 'Online', 2 => 'Standby' diff --git a/.docs/row.md b/.docs/row.md index 21393e57..e27fd92e 100644 --- a/.docs/row.md +++ b/.docs/row.md @@ -17,7 +17,7 @@ Table of contents Now all rows have to provide group action or editing. Or some other of your actions. You can forbid group actions rendering for some items like this: ```php -$grid->allowRowsGroupAction(function(Row $item): bool { +$datagrid->allowRowsGroupAction(function(Row $item): bool { return $item->id !== 2; }); ``` diff --git a/.docs/template.md b/.docs/template.md index dcc2eb99..f83c126a 100644 --- a/.docs/template.md +++ b/.docs/template.md @@ -14,7 +14,7 @@ Table of contents When you set custom datagrid template, you will probably want to extend it. There are some `blocks` defined, so you can extend just some blocks. Presenter: ```php -$grid->setTemplateFile(__DIR__ . '/../../custom_datagrid_template.latte'); +$datagrid->setTemplateFile(__DIR__ . '/../../custom_datagrid_template.latte'); ``` Template: diff --git a/src/Column/Action.php b/src/Column/Action.php index 42743bc9..d3920852 100755 --- a/src/Column/Action.php +++ b/src/Column/Action.php @@ -48,16 +48,16 @@ class Action extends Column private $customHref; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, protected string $href, string $name, protected array $params ) { - parent::__construct($grid, $key, '', $name); + parent::__construct($datagrid, $key, '', $name); - $this->class = sprintf('btn btn-xs %s', $grid::$btnSecondaryClass); + $this->class = sprintf('btn btn-xs %s', $datagrid::$btnSecondaryClass); } public function render(Row $row): mixed @@ -73,7 +73,7 @@ public function render(Row $row): mixed } $link = $this->getCustomHref($row) ?? $this->createLink( - $this->grid, + $this->datagrid, $this->href, $this->getItemParams($row, $this->params) + $this->parameters ); @@ -345,7 +345,7 @@ protected function checkPropertyStringOrCallable(mixed $property, string $name): protected function translate(string $message): string { - return $this->grid->getTranslator()->translate($message); + return $this->datagrid->getTranslator()->translate($message); } } diff --git a/src/Column/ActionCallback.php b/src/Column/ActionCallback.php index 94ecc48d..fd0a0af3 100644 --- a/src/Column/ActionCallback.php +++ b/src/Column/ActionCallback.php @@ -19,14 +19,14 @@ class ActionCallback extends Action /** * Create link to datagrid::handleActionCallback() to fire custom callback */ - protected function createLink(Datagrid $grid, string $href, array $params): string + protected function createLink(Datagrid $datagrid, string $href, array $params): string { /** * Int case of ActionCallback, $this->href is a identifier of user callback */ $params += ['__key' => $this->href]; - return $this->grid->link('actionCallback!', $params); + return $this->datagrid->link('actionCallback!', $params); } } diff --git a/src/Column/Column.php b/src/Column/Column.php index d46ef066..76482cb5 100644 --- a/src/Column/Column.php +++ b/src/Column/Column.php @@ -277,7 +277,7 @@ public function setSort(string $sort): self */ public function getSortNext(): array { - $defaultSort = $this->grid->getColumnDefaultSort($this->key); + $defaultSort = $this->datagrid->getColumnDefaultSort($this->key); if ($this->sort === 'ASC') { return [$this->key => $defaultSort === 'DESC' ? false : 'DESC']; @@ -498,7 +498,7 @@ public function getElementForRender(string $tag, string $key, ?Row $row = null): $el->appendAttribute('class', sprintf('col-%s', $key)); if ($row !== null && $tag === 'td' && $this->isEditable($row)) { - $link = $this->grid->link('edit!', ['key' => $key, 'id' => $row->getId()]); + $link = $this->datagrid->link('edit!', ['key' => $key, 'id' => $row->getId()]); $el->data('datagrid-editable-url', $link); @@ -524,7 +524,7 @@ public function setDefaultHide(bool $defaultHide = true): self $this->defaultHide = $defaultHide; if ($defaultHide) { - $this->grid->setSomeColumnDefaultHide($defaultHide); + $this->datagrid->setSomeColumnDefaultHide($defaultHide); } return $this; diff --git a/src/Column/ColumnLink.php b/src/Column/ColumnLink.php index 7be353cf..f60203e1 100644 --- a/src/Column/ColumnLink.php +++ b/src/Column/ColumnLink.php @@ -23,7 +23,7 @@ class ColumnLink extends Column protected array $parameters = []; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $column, string $name, @@ -31,7 +31,7 @@ public function __construct( protected array $params ) { - parent::__construct($grid, $key, $column, $name); + parent::__construct($datagrid, $key, $column, $name); } public function render(Row $row): mixed @@ -55,7 +55,7 @@ public function render(Row $row): mixed $a = Html::el('a') ->href($this->createLink( - $this->grid, + $this->datagrid, $this->href, $this->getItemParams($row, $this->params) + $this->parameters )); diff --git a/src/Column/ColumnStatus.php b/src/Column/ColumnStatus.php index 9a92a80e..fcb9b9d5 100644 --- a/src/Column/ColumnStatus.php +++ b/src/Column/ColumnStatus.php @@ -28,13 +28,13 @@ class ColumnStatus extends Column protected array $options = []; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $column, string $name ) { - parent::__construct($grid, $key, $column, $name); + parent::__construct($datagrid, $key, $column, $name); $this->key = $key; @@ -93,7 +93,7 @@ public function addOption(mixed $value, string $text): Option throw new DatagridColumnStatusException('Option value has to be scalar'); } - $option = new Option($this->grid, $this, $value, $text); + $option = new Option($this->datagrid, $this, $value, $text); $this->options[] = $option; diff --git a/src/Column/FilterableColumn.php b/src/Column/FilterableColumn.php index b89bd07a..ccad8209 100644 --- a/src/Column/FilterableColumn.php +++ b/src/Column/FilterableColumn.php @@ -13,7 +13,7 @@ abstract class FilterableColumn { - public function __construct(protected Datagrid $grid, protected string $key, protected string $column, protected string $name) + public function __construct(protected Datagrid $datagrid, protected string $key, protected string $column, protected string $name) { } @@ -27,7 +27,7 @@ public function setFilterText(string|array|null $columns = null): FilterText : $columns; } - return $this->grid->addFilterText($this->key, $this->name, $columns); + return $this->datagrid->addFilterText($this->key, $this->name, $columns); } public function setFilterSelect( @@ -37,7 +37,7 @@ public function setFilterSelect( { $column ??= $this->column; - return $this->grid->addFilterSelect($this->key, $this->name, $options, $column); + return $this->datagrid->addFilterSelect($this->key, $this->name, $options, $column); } public function setFilterMultiSelect( @@ -47,14 +47,14 @@ public function setFilterMultiSelect( { $column ??= $this->column; - return $this->grid->addFilterMultiSelect($this->key, $this->name, $options, $column); + return $this->datagrid->addFilterMultiSelect($this->key, $this->name, $options, $column); } public function setFilterDate(?string $column = null): FilterDate { $column ??= $this->column; - return $this->grid->addFilterDate($this->key, $this->name, $column); + return $this->datagrid->addFilterDate($this->key, $this->name, $column); } public function setFilterRange( @@ -64,7 +64,7 @@ public function setFilterRange( { $column ??= $this->column; - return $this->grid->addFilterRange($this->key, $this->name, $column, $nameSecond); + return $this->datagrid->addFilterRange($this->key, $this->name, $column, $nameSecond); } public function setFilterDateRange( @@ -74,7 +74,7 @@ public function setFilterDateRange( { $column ??= $this->column; - return $this->grid->addFilterDateRange($this->key, $this->name, $column, $nameSecond); + return $this->datagrid->addFilterDateRange($this->key, $this->name, $column, $nameSecond); } } diff --git a/src/Column/ItemDetail.php b/src/Column/ItemDetail.php index 6259fdbb..d6e00ec7 100644 --- a/src/Column/ItemDetail.php +++ b/src/Column/ItemDetail.php @@ -39,10 +39,10 @@ class ItemDetail protected array $templateParameters = []; - public function __construct(protected Datagrid $grid, protected string $primaryWhereColumn) + public function __construct(protected Datagrid $datagrid, protected string $primaryWhereColumn) { $this->title = 'contributte_datagrid.show'; - $this->class = sprintf('btn btn-xs %s ajax', $grid::$btnSecondaryClass); + $this->class = sprintf('btn btn-xs %s ajax', $datagrid::$btnSecondaryClass); $this->icon = 'eye'; } @@ -52,10 +52,10 @@ public function __construct(protected Datagrid $grid, protected string $primaryW public function renderButton(Row $row): Html { $a = Html::el('a') - ->href($this->grid->link('getItemDetail!', ['id' => $row->getId()])) + ->href($this->datagrid->link('getItemDetail!', ['id' => $row->getId()])) ->data('toggle-detail', $row->getId()) - ->data('toggle-detail-grid-fullname', $this->grid->getFullName()) - ->data('toggle-detail-grid', $this->grid->getName()); + ->data('toggle-detail-grid-fullname', $this->datagrid->getFullName()) + ->data('toggle-detail-grid', $this->datagrid->getName()); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); @@ -64,7 +64,7 @@ public function renderButton(Row $row): Html if ($this->title !== null) { $a->setAttribute( 'title', - $this->grid->getTranslator()->translate($this->title) + $this->datagrid->getTranslator()->translate($this->title) ); } diff --git a/src/Column/MultiAction.php b/src/Column/MultiAction.php index 1439fb59..b2bee3a7 100644 --- a/src/Column/MultiAction.php +++ b/src/Column/MultiAction.php @@ -25,7 +25,7 @@ class MultiAction extends Column use TButtonCaret; use TLink; - protected Datagrid $grid; + protected Datagrid $datagrid; protected string $name; @@ -34,9 +34,9 @@ class MultiAction extends Column /** @var array|callable[] */ private array $rowConditions = []; - public function __construct(Datagrid $grid, string $key, string $name) + public function __construct(Datagrid $datagrid, string $key, string $name) { - parent::__construct($grid, $key, '', $name); + parent::__construct($datagrid, $key, '', $name); $this->setTemplate(__DIR__ . '/../templates/column_multi_action.latte'); } @@ -49,7 +49,7 @@ public function renderButton(): Html $this->tryAddIcon($button, $this->getIcon(), $this->getName()); - $button->addText($this->grid->getTranslator()->translate($this->name)); + $button->addText($this->datagrid->getTranslator()->translate($this->name)); if ($this->hasCaret()) { $button->addHtml(' '); @@ -59,7 +59,7 @@ public function renderButton(): Html if ($this->getTitle() !== null) { $button->setAttribute( 'title', - $this->grid->getTranslator()->translate($this->getTitle()) + $this->datagrid->getTranslator()->translate($this->getTitle()) ); } @@ -89,10 +89,10 @@ public function addAction( $href ??= $key; if ($params === null) { - $params = [$this->grid->getPrimaryKey()]; + $params = [$this->datagrid->getPrimaryKey()]; } - $action = new Action($this->grid, $key, $href, $name, $params); + $action = new Action($this->datagrid, $key, $href, $name, $params); $action->setClass('dropdown-item datagrid-multiaction-dropdown-item'); diff --git a/src/Datagrid.php b/src/Datagrid.php index 11e35fcd..fb722d0f 100644 --- a/src/Datagrid.php +++ b/src/Datagrid.php @@ -1982,7 +1982,7 @@ public function reload(array $snippets = []): void public function reloadTheWholeGrid(): void { if ($this->getPresenterInstance()->isAjax()) { - $this->redrawControl('grid'); + $this->redrawControl('datagrid'); $this->getPresenterInstance()->payload->_datagrid_url = $this->refreshURL; $this->getPresenterInstance()->payload->_datagrid_name = $this->getFullName(); diff --git a/src/Export/Export.php b/src/Export/Export.php index 08de0772..3e9783e1 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -34,7 +34,7 @@ class Export protected ?string $target = null; public function __construct( - protected Datagrid $grid, + protected Datagrid $datagrid, string $text, callable $callback, protected bool $filtered @@ -49,7 +49,7 @@ public function render(): Html { $a = Html::el('a', [ 'class' => [$this->class], - 'title' => $this->grid->getTranslator()->translate($this->getTitle()), + 'title' => $this->datagrid->getTranslator()->translate($this->getTitle()), 'href' => $this->link, 'target' => $this->target, ]); @@ -57,10 +57,10 @@ public function render(): Html $this->tryAddIcon( $a, $this->getIcon(), - $this->grid->getTranslator()->translate($this->getTitle()) + $this->datagrid->getTranslator()->translate($this->getTitle()) ); - $a->addText($this->grid->getTranslator()->translate($this->text)); + $a->addText($this->datagrid->getTranslator()->translate($this->text)); if ($this->isAjax()) { $a->appendAttribute('class', 'ajax'); @@ -145,7 +145,7 @@ public function isFiltered(): bool */ public function invoke(iterable $data): void { - ($this->callback)($data, $this->grid); + ($this->callback)($data, $this->datagrid); } /** diff --git a/src/Export/ExportCsv.php b/src/Export/ExportCsv.php index eb84ddfd..9fd28ce7 100644 --- a/src/Export/ExportCsv.php +++ b/src/Export/ExportCsv.php @@ -10,7 +10,7 @@ class ExportCsv extends Export { public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $text, string $name, bool $filtered, @@ -24,7 +24,7 @@ public function __construct( } parent::__construct( - $grid, + $datagrid, $text, $this->getExportCallback($name, $outputEncoding, $delimiter, $includeBom), $filtered @@ -40,7 +40,7 @@ private function getExportCallback( { return function ( array $data, - Datagrid $grid + Datagrid $datagrid ) use ( $name, $outputEncoding, @@ -50,12 +50,12 @@ private function getExportCallback( $columns = $this->getColumns(); if ($columns === []) { - $columns = $this->grid->getColumns(); + $columns = $this->datagrid->getColumns(); } - $csvDataModel = new CsvDataModel($data, $columns, $this->grid->getTranslator()); + $csvDataModel = new CsvDataModel($data, $columns, $this->datagrid->getTranslator()); - $this->grid->getPresenter()->sendResponse(new CSVResponse( + $this->datagrid->getPresenter()->sendResponse(new CSVResponse( $csvDataModel->getSimpleData(), $name, $outputEncoding, diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index 6ba00ab5..c86f67e9 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -29,7 +29,7 @@ abstract class Filter private ?string $placeholder = null; - public function __construct(protected Datagrid $grid, protected string $key, protected string $name) + public function __construct(protected Datagrid $datagrid, protected string $key, protected string $name) { } @@ -156,7 +156,7 @@ public function getAttributes(): array protected function addAttributes(BaseControl $input): BaseControl { - if ($this->grid->hasAutoSubmit()) { + if ($this->datagrid->hasAutoSubmit()) { $input->setHtmlAttribute('data-autosubmit', true); } else { $input->setHtmlAttribute('data-datagrid-manualsubmit', true); diff --git a/src/Filter/FilterDate.php b/src/Filter/FilterDate.php index 171211a3..bfe58ade 100644 --- a/src/Filter/FilterDate.php +++ b/src/Filter/FilterDate.php @@ -25,7 +25,7 @@ public function addToFormContainer(Container $container): void $this->addAttributes($control); - if ($this->grid->hasAutoSubmit()) { + if ($this->datagrid->hasAutoSubmit()) { $control->setHtmlAttribute('data-autosubmit-change', true); } diff --git a/src/Filter/FilterDateRange.php b/src/Filter/FilterDateRange.php index 37916f1f..84fc5d61 100644 --- a/src/Filter/FilterDateRange.php +++ b/src/Filter/FilterDateRange.php @@ -39,7 +39,7 @@ public function addToFormContainer(Container $container): void $this->addAttributes($from); $this->addAttributes($to); - if ($this->grid->hasAutoSubmit()) { + if ($this->datagrid->hasAutoSubmit()) { $from->setHtmlAttribute('data-autosubmit-change', true); $to->setHtmlAttribute('data-autosubmit-change', true); } diff --git a/src/Filter/FilterMultiSelect.php b/src/Filter/FilterMultiSelect.php index b41fb693..783ce063 100644 --- a/src/Filter/FilterMultiSelect.php +++ b/src/Filter/FilterMultiSelect.php @@ -19,14 +19,14 @@ class FilterMultiSelect extends FilterSelect ]; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $name, array $options, string $column ) { - parent::__construct($grid, $key, $name, $options, $column); + parent::__construct($datagrid, $key, $name, $options, $column); $this->addAttribute('data-selected-icon-check', Datagrid::$iconPrefix . 'check'); } diff --git a/src/Filter/FilterRange.php b/src/Filter/FilterRange.php index c796d5ef..a29437d9 100644 --- a/src/Filter/FilterRange.php +++ b/src/Filter/FilterRange.php @@ -15,14 +15,14 @@ class FilterRange extends OneColumnFilter protected ?string $type = 'range'; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $name, string $column, protected string $nameSecond ) { - parent::__construct($grid, $key, $name, $column); + parent::__construct($datagrid, $key, $name, $column); } public function addToFormContainer(Container $container): void diff --git a/src/Filter/FilterSelect.php b/src/Filter/FilterSelect.php index 2cf8c51b..aa22d282 100644 --- a/src/Filter/FilterSelect.php +++ b/src/Filter/FilterSelect.php @@ -24,14 +24,14 @@ class FilterSelect extends OneColumnFilter protected ?string $prompt = null; public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $name, protected array $options, string $column ) { - parent::__construct($grid, $key, $name, $column); + parent::__construct($datagrid, $key, $name, $column); } public function addToFormContainer(Container $container): void diff --git a/src/Filter/FilterText.php b/src/Filter/FilterText.php index 664becb5..eb2828c9 100644 --- a/src/Filter/FilterText.php +++ b/src/Filter/FilterText.php @@ -20,13 +20,13 @@ class FilterText extends Filter * @param array|string[] $columns */ public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $name, protected array $columns ) { - parent::__construct($grid, $key, $name); + parent::__construct($datagrid, $key, $name); } /** diff --git a/src/Filter/OneColumnFilter.php b/src/Filter/OneColumnFilter.php index 2a2a7821..c5c79bc1 100644 --- a/src/Filter/OneColumnFilter.php +++ b/src/Filter/OneColumnFilter.php @@ -8,13 +8,13 @@ abstract class OneColumnFilter extends Filter { public function __construct( - Datagrid $grid, + Datagrid $datagrid, string $key, string $name, protected string $column ) { - parent::__construct($grid, $key, $name); + parent::__construct($datagrid, $key, $name); } /** diff --git a/src/Filter/SubmitButton.php b/src/Filter/SubmitButton.php index d43918bd..33b95812 100644 --- a/src/Filter/SubmitButton.php +++ b/src/Filter/SubmitButton.php @@ -21,7 +21,7 @@ class SubmitButton extends Button use TButtonTitle; use TButtonText; - public function __construct(protected Datagrid $grid) + public function __construct(protected Datagrid $datagrid) { parent::__construct($this->text); @@ -52,7 +52,7 @@ public function getControl(Stringable|string|null $caption = null): Html } } - $el->addText($this->grid->getTranslator()->translate($this->getText())); + $el->addText($this->datagrid->getTranslator()->translate($this->getText())); return $el; } diff --git a/src/InlineEdit/InlineEdit.php b/src/InlineEdit/InlineEdit.php index ded87e13..bcee0052 100644 --- a/src/InlineEdit/InlineEdit.php +++ b/src/InlineEdit/InlineEdit.php @@ -61,10 +61,10 @@ class InlineEdit /** @var array */ protected array $dataAttributes = []; - public function __construct(protected Datagrid $grid, protected ?string $primaryWhereColumn = null) + public function __construct(protected Datagrid $datagrid, protected ?string $primaryWhereColumn = null) { $this->title = 'contributte_datagrid.edit'; - $this->class = sprintf('btn btn-xs %s ajax', $grid::$btnSecondaryClass); + $this->class = sprintf('btn btn-xs %s ajax', $datagrid::$btnSecondaryClass); $this->icon = 'pencil pencil-alt'; $this->onControlAfterAdd[] = [$this, 'addControlsClasses']; @@ -93,7 +93,7 @@ public function getPrimaryWhereColumn(): ?string public function renderButton(Row $row): Html { $a = Html::el('a') - ->href($this->grid->link('inlineEdit!', ['id' => $row->getId()])); + ->href($this->datagrid->link('inlineEdit!', ['id' => $row->getId()])); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); @@ -108,7 +108,7 @@ public function renderButton(Row $row): Html if ($this->title !== null) { $a->setAttribute( 'title', - $this->grid->getTranslator()->translate($this->title) + $this->datagrid->getTranslator()->translate($this->title) ); } @@ -127,7 +127,7 @@ public function renderButton(Row $row): Html public function renderButtonAdd(): Html { $a = Html::el('a') - ->href($this->grid->link('showInlineAdd!')); + ->href($this->datagrid->link('showInlineAdd!')); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); @@ -142,7 +142,7 @@ public function renderButtonAdd(): Html if ($this->title !== null) { $a->setAttribute( 'title', - $this->grid->getTranslator()->translate($this->title) + $this->datagrid->getTranslator()->translate($this->title) ); } diff --git a/src/Status/Option.php b/src/Status/Option.php index 24cb5f23..1c0542b2 100644 --- a/src/Status/Option.php +++ b/src/Status/Option.php @@ -27,7 +27,7 @@ class Option protected ?IConfirmation $confirmation = null; - public function __construct(private Datagrid $grid, protected ColumnStatus $columnStatus, protected mixed $value, protected string $text) + public function __construct(private Datagrid $datagrid, protected ColumnStatus $columnStatus, protected mixed $value, protected string $text) { } @@ -161,7 +161,7 @@ public function getConfirmationDialog(Row $row): ?string } if ($this->confirmation instanceof StringConfirmation) { - $question = $this->grid->getTranslator()->translate($this->confirmation->getQuestion()); + $question = $this->datagrid->getTranslator()->translate($this->confirmation->getQuestion()); if ($this->confirmation->getPlaceholderName() === null) { return $question; diff --git a/src/Toolbar/ToolbarButton.php b/src/Toolbar/ToolbarButton.php index 96579bcc..4e671738 100644 --- a/src/Toolbar/ToolbarButton.php +++ b/src/Toolbar/ToolbarButton.php @@ -31,7 +31,7 @@ class ToolbarButton /** * Toolbar button constructor */ - public function __construct(protected Datagrid $grid, protected string $href, string $text, protected array $params = []) + public function __construct(protected Datagrid $datagrid, protected string $href, string $text, protected array $params = []) { $this->text = $text; } @@ -48,7 +48,7 @@ public function renderButton(): Html // Do not use renderer } - $link = $this->createLink($this->grid, $this->href, $this->params); + $link = $this->createLink($this->datagrid, $this->href, $this->params); $a = Html::el('a')->href($link); @@ -58,12 +58,12 @@ public function renderButton(): Html $a->addAttributes($this->attributes); } - $a->addText($this->grid->getTranslator()->translate($this->text)); + $a->addText($this->datagrid->getTranslator()->translate($this->text)); if ($this->getTitle() !== null) { $a->setAttribute( 'title', - $this->grid->getTranslator()->translate($this->getTitle()) + $this->datagrid->getTranslator()->translate($this->getTitle()) ); } diff --git a/src/Traits/TLink.php b/src/Traits/TLink.php index 57f120ee..c421ac73 100644 --- a/src/Traits/TLink.php +++ b/src/Traits/TLink.php @@ -21,14 +21,14 @@ trait TLink * @throws UnexpectedValueException */ protected function createLink( - Datagrid $grid, + Datagrid $datagrid, string $href, array $params ): string { - $targetComponent = $grid; + $targetComponent = $datagrid; - $presenter = $grid->getPresenter(); + $presenter = $datagrid->getPresenter(); if (str_contains($href, ':')) { return $presenter->link($href, $params); @@ -38,7 +38,7 @@ protected function createLink( $targetComponent = $targetComponent->getParent(); if (!$targetComponent instanceof Component) { - throw $this->createHierarchyLookupException($grid, $href, $params); + throw $this->createHierarchyLookupException($datagrid, $href, $params); } try { @@ -63,17 +63,17 @@ protected function createLink( } // Went 10 steps up to the Presenter and did not find any signal handler - throw $this->createHierarchyLookupException($grid, $href, $params); + throw $this->createHierarchyLookupException($datagrid, $href, $params); } private function createHierarchyLookupException( - Datagrid $grid, + Datagrid $datagrid, string $href, array $params ): DatagridLinkCreationException { - $parent = $grid->getParent(); - $presenter = $grid->getPresenter(); + $parent = $datagrid->getParent(); + $presenter = $datagrid->getPresenter(); if ($parent === null) { throw new UnexpectedValueException( diff --git a/tests/Cases/ColumnActionTest.phpt b/tests/Cases/ColumnActionTest.phpt index de793733..2faf28a0 100755 --- a/tests/Cases/ColumnActionTest.phpt +++ b/tests/Cases/ColumnActionTest.phpt @@ -16,26 +16,26 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnActionTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function render(Action $column): string { - $item = new Row($this->grid, ['id' => 1, 'name' => 'John'], 'id'); + $item = new Row($this->datagrid, ['id' => 1, 'name' => 'John'], 'id'); return (string) $column->render($item); } public function testActionDuplicityColumn(): void { - $this->grid->addAction('action', 'Do', 'doStuff!'); + $this->datagrid->addAction('action', 'Do', 'doStuff!'); - $grid = $this->grid; + $grid = $this->datagrid; $add_action = function () use ($grid): void { $grid->addAction('action', 'Do', 'doStuff!'); }; @@ -45,27 +45,27 @@ final class ColumnActionTest extends TestCase public function testActionLink(): void { - $action = $this->grid->addAction('action', 'Do', 'doStuff!'); + $action = $this->datagrid->addAction('action', 'Do', 'doStuff!'); Assert::same( 'Do', $this->render($action) ); - $action = $this->grid->addAction('detail', 'Do'); + $action = $this->datagrid->addAction('detail', 'Do'); Assert::same( 'Do', $this->render($action) ); - $action = $this->grid->addAction('title', 'Do', 'detail', ['id', 'name']); + $action = $this->datagrid->addAction('title', 'Do', 'detail', ['id', 'name']); Assert::same( 'Do', $this->render($action) ); - $action = $this->grid->addAction('title2', 'Do', 'detail', [ + $action = $this->datagrid->addAction('title2', 'Do', 'detail', [ 'id' => 'name', 'name' => 'id', ]); @@ -77,7 +77,7 @@ final class ColumnActionTest extends TestCase public function testActionIcon(): void { - $action = $this->grid->addAction('action', 'Do', 'doStuff!'); + $action = $this->datagrid->addAction('action', 'Do', 'doStuff!'); Datagrid::$iconPrefix = 'icon-'; $action->setIcon('user'); @@ -90,7 +90,7 @@ final class ColumnActionTest extends TestCase public function testActionClass(): void { - $action = $this->grid->addAction('action', 'Do', 'doStuff!')->setClass('btn'); + $action = $this->datagrid->addAction('action', 'Do', 'doStuff!')->setClass('btn'); Assert::same('Do', $this->render($action)); @@ -101,7 +101,7 @@ final class ColumnActionTest extends TestCase public function testActionTitle(): void { - $action = $this->grid->addAction('action', 'Do', 'doStuff!')->setTitle('hello'); + $action = $this->datagrid->addAction('action', 'Do', 'doStuff!')->setTitle('hello'); Assert::same( 'Do', @@ -111,21 +111,21 @@ final class ColumnActionTest extends TestCase public function testActionCustomHref(): void { - $action = $this->grid->addAction('action1', 'Do')->setCustomHref('https://www.example.com/'); + $action = $this->datagrid->addAction('action1', 'Do')->setCustomHref('https://www.example.com/'); Assert::same( 'Do', $this->render($action) ); - $action = $this->grid->addAction('action2', 'Do')->setCustomHref(fn ($rowItem) => 'https://www.example.com/?name=' . $rowItem['name']); + $action = $this->datagrid->addAction('action2', 'Do')->setCustomHref(fn ($rowItem) => 'https://www.example.com/?name=' . $rowItem['name']); Assert::same( 'Do', $this->render($action) ); - $action = $this->grid->addAction('action3', 'Do')->setCustomHref(fn ($rowItem) => '/preview/user/?id=' . $rowItem['id']); + $action = $this->datagrid->addAction('action3', 'Do')->setCustomHref(fn ($rowItem) => '/preview/user/?id=' . $rowItem['id']); Assert::same( 'Do', @@ -135,7 +135,7 @@ final class ColumnActionTest extends TestCase public function testActionConfirm(): void { - $action = $this->grid->addAction('action', 'Do', 'doStuff!') + $action = $this->datagrid->addAction('action', 'Do', 'doStuff!') ->setConfirmation(new StringConfirmation('Really?')); Assert::same( @@ -146,11 +146,11 @@ final class ColumnActionTest extends TestCase public function testActionRenderCondition(): void { - $action = $this->grid->addAction('action1', 'Do', 'doStuff!')->setRenderCondition(fn () => true); + $action = $this->datagrid->addAction('action1', 'Do', 'doStuff!')->setRenderCondition(fn () => true); Assert::same('Do', $this->render($action)); - $action = $this->grid->addAction('action2', 'Do', 'doStuff!')->setRenderCondition(fn () => false); + $action = $this->datagrid->addAction('action2', 'Do', 'doStuff!')->setRenderCondition(fn () => false); Assert::same('', $this->render($action)); } diff --git a/tests/Cases/ColumnDateTimeTest.phpt b/tests/Cases/ColumnDateTimeTest.phpt index ee870b87..1fb806da 100644 --- a/tests/Cases/ColumnDateTimeTest.phpt +++ b/tests/Cases/ColumnDateTimeTest.phpt @@ -16,18 +16,18 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnDateTimeTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function render(ColumnDateTime $column): string { $datetime = DateTime::createFromFormat('Y-m-d H:i:s', '2015-12-15 22:58:42'); - $item = new Row($this->grid, ['id' => 1, 'name' => 'John', 'date' => $datetime], 'id'); + $item = new Row($this->datagrid, ['id' => 1, 'name' => 'John', 'date' => $datetime], 'id'); return $column->render($item); } @@ -37,7 +37,7 @@ final class ColumnDateTimeTest extends TestCase /** * Defaul forma is 'j. n. Y' */ - $datetime = $this->grid->addColumnDateTime('date', 'Date'); + $datetime = $this->datagrid->addColumnDateTime('date', 'Date'); Assert::same('15. 12. 2015', $this->render($datetime)); $datetime->setFormat('H:i:s'); diff --git a/tests/Cases/ColumnLinkTest.phpt b/tests/Cases/ColumnLinkTest.phpt index eac5dfd6..458169ec 100644 --- a/tests/Cases/ColumnLinkTest.phpt +++ b/tests/Cases/ColumnLinkTest.phpt @@ -15,39 +15,39 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnLinkTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function render(ColumnLink $column): string { - $item = new Row($this->grid, ['id' => 1, 'name' => 'John'], 'id'); + $item = new Row($this->datagrid, ['id' => 1, 'name' => 'John'], 'id'); return (string) $column->render($item); } public function testLink(): void { - $link = $this->grid->addColumnLink('name', 'Href'); + $link = $this->datagrid->addColumnLink('name', 'Href'); Assert::same('John', $this->render($link)); - $link = $this->grid->addColumnLink('name2', 'Href', 'edit', 'name'); + $link = $this->datagrid->addColumnLink('name2', 'Href', 'edit', 'name'); Assert::same('John', $this->render($link)); - $link = $this->grid->addColumnLink('name3', 'Href', 'edit', 'id'); + $link = $this->datagrid->addColumnLink('name3', 'Href', 'edit', 'id'); Assert::same('1', $this->render($link)); - $link = $this->grid->addColumnLink('name4', 'Href', 'edit', 'id', ['name']); + $link = $this->datagrid->addColumnLink('name4', 'Href', 'edit', 'id', ['name']); Assert::same('1', $this->render($link)); - $link = $this->grid->addColumnLink('name5', 'Href', 'edit', 'id', ['name', 'id']); + $link = $this->datagrid->addColumnLink('name5', 'Href', 'edit', 'id', ['name', 'id']); Assert::same('1', $this->render($link)); - $link = $this->grid->addColumnLink('name6', 'Href', 'edit', 'id', [ + $link = $this->datagrid->addColumnLink('name6', 'Href', 'edit', 'id', [ 'name' => 'id', 'id' => 'name', ]); @@ -56,7 +56,7 @@ final class ColumnLinkTest extends TestCase public function testLinkClass(): void { - $link = $this->grid->addColumnLink('name', 'Href')->setClass('btn'); + $link = $this->datagrid->addColumnLink('name', 'Href')->setClass('btn'); Assert::same('John', $this->render($link)); $link->setClass(null); @@ -65,7 +65,7 @@ final class ColumnLinkTest extends TestCase public function testLinkTitle(): void { - $link = $this->grid->addColumnLink('name', 'Href')->setTitle('Hello'); + $link = $this->datagrid->addColumnLink('name', 'Href')->setTitle('Hello'); Assert::same('John', $this->render($link)); } diff --git a/tests/Cases/ColumnNumberTest.phpt b/tests/Cases/ColumnNumberTest.phpt index 79cecf29..e70fa81b 100644 --- a/tests/Cases/ColumnNumberTest.phpt +++ b/tests/Cases/ColumnNumberTest.phpt @@ -15,27 +15,27 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnNumberTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function render(ColumnNumber $column): string { - $item = new Row($this->grid, ['id' => 1, 'name' => 'John', 'amount' => 345678.567], 'id'); + $item = new Row($this->datagrid, ['id' => 1, 'name' => 'John', 'amount' => 345678.567], 'id'); return $column->render($item); } public function testFormat(): void { - $number = $this->grid->addColumnNumber('amount', 'Amount'); + $number = $this->datagrid->addColumnNumber('amount', 'Amount'); Assert::same('345 679', $this->render($number)); - $number = $this->grid->addColumnNumber('amount2', 'Amount', 'amount')->setFormat(2, '.', ','); + $number = $this->datagrid->addColumnNumber('amount2', 'Amount', 'amount')->setFormat(2, '.', ','); Assert::same('345,678.57', $this->render($number)); } diff --git a/tests/Cases/ColumnStatusTest.phpt b/tests/Cases/ColumnStatusTest.phpt index f5630261..f094e491 100644 --- a/tests/Cases/ColumnStatusTest.phpt +++ b/tests/Cases/ColumnStatusTest.phpt @@ -14,17 +14,17 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnStatusTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testStatus(): void { - $grid = $this->grid; + $grid = $this->datagrid; $grid->addColumnStatus('status', 'Status') ->setCaret(false) @@ -56,7 +56,7 @@ final class ColumnStatusTest extends TestCase public function testRemoveColumn(): void { - $grid = $this->grid; + $grid = $this->datagrid; $grid->addColumnText('test', 'Test'); $grid->removeColumn('test'); $grid->getColumnsVisibility(); diff --git a/tests/Cases/ColumnTranslatableTest.phpt b/tests/Cases/ColumnTranslatableTest.phpt index 53702baf..9db4f766 100644 --- a/tests/Cases/ColumnTranslatableTest.phpt +++ b/tests/Cases/ColumnTranslatableTest.phpt @@ -13,17 +13,17 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ColumnTranslatableTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testTranslatable(): void { - $grid = $this->grid; + $grid = $this->datagrid; $grid->addColumnText('translatable', 'translatable'); @@ -34,7 +34,7 @@ final class ColumnTranslatableTest extends TestCase public function testDisabledTranslating(): void { - $grid = $this->grid; + $grid = $this->datagrid; $grid->addColumnText('non_translatable', 'non_translatable') ->setTranslatableHeader(false); diff --git a/tests/Cases/CreateLinkTest.phpt b/tests/Cases/CreateLinkTest.phpt index 649ba414..07dd1701 100644 --- a/tests/Cases/CreateLinkTest.phpt +++ b/tests/Cases/CreateLinkTest.phpt @@ -16,30 +16,30 @@ final class CreateLinkTest extends TestCase use TLink; - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactoryRouter(); - $this->grid = $factory->createTestingDatagrid()->getComponent('grid'); + $this->datagrid = $factory->createTestingDatagrid()->getComponent('datagrid'); } public function testActionLink(): void { - $this->grid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; - $link = $this->createLink($this->grid, 'edit', ['id' => 1]); + $this->datagrid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; + $link = $this->createLink($this->datagrid, 'edit', ['id' => 1]); Assert::same('/index.php?id=1&action=edit&presenter=Test', $link); - $this->grid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; - $link = $this->createLink($this->grid, 'edit', ['id' => 1]); + $this->datagrid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; + $link = $this->createLink($this->datagrid, 'edit', ['id' => 1]); Assert::same('/index.php?id=1&action=edit&presenter=Test', $link); - $this->grid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; - $link = $this->createLink($this->grid, 'edit', ['id' => 1]); + $this->datagrid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; + $link = $this->createLink($this->datagrid, 'edit', ['id' => 1]); Assert::same('/index.php?id=1&action=edit&presenter=Test', $link); - $this->grid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; - $link = $this->createLink($this->grid, 'edit', ['id' => 1]); + $this->datagrid->getPresenter()->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION; + $link = $this->createLink($this->datagrid, 'edit', ['id' => 1]); Assert::same('/index.php?id=1&action=edit&presenter=Test', $link); } diff --git a/tests/Cases/DataSources/ArrayDataSourceTest.phpt b/tests/Cases/DataSources/ArrayDataSourceTest.phpt index 2be5df94..d858d586 100644 --- a/tests/Cases/DataSources/ArrayDataSourceTest.phpt +++ b/tests/Cases/DataSources/ArrayDataSourceTest.phpt @@ -15,7 +15,7 @@ final class ArrayDataSourceTest extends BaseDataSourceTest { $this->ds = new ArrayDataSource($this->data); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } } diff --git a/tests/Cases/DataSources/BaseDataSourceTest.phpt b/tests/Cases/DataSources/BaseDataSourceTest.phpt index 39971400..b67e5381 100644 --- a/tests/Cases/DataSources/BaseDataSourceTest.phpt +++ b/tests/Cases/DataSources/BaseDataSourceTest.phpt @@ -28,7 +28,7 @@ abstract class BaseDataSourceTest extends TestCase protected IDataSource $ds; - protected Datagrid $grid; + protected Datagrid $datagrid; public function testGetCount(): void { @@ -37,7 +37,7 @@ abstract class BaseDataSourceTest extends TestCase public function testGetFilteredCount(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['name']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name']); $filter->setValue('John Red'); $this->ds->filter([$filter]); @@ -51,7 +51,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterSingleColumn(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['name']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name']); $filter->setValue('John Red'); $this->ds->filter([$filter]); @@ -63,7 +63,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterMultipleColumns(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['name', 'address']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name', 'address']); $filter->setValue('lu'); $this->ds->filter([$filter]); @@ -79,7 +79,7 @@ abstract class BaseDataSourceTest extends TestCase /** * Single column - SplitWordsSearch => FALSE */ - $filter = new FilterText($this->grid, 'a', 'b', ['name']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name']); $filter->setSplitWordsSearch(false); $filter->setValue('John Red'); @@ -90,7 +90,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterRangeMin(): void { - $filter = new FilterRange($this->grid, 'a', 'b', 'age', '-'); + $filter = new FilterRange($this->datagrid, 'a', 'b', 'age', '-'); $filter->setValue(['from' => 40]); $this->ds->filter([$filter]); @@ -103,7 +103,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterRangeMax(): void { - $filter = new FilterRange($this->grid, 'a', 'b', 'age', '-'); + $filter = new FilterRange($this->datagrid, 'a', 'b', 'age', '-'); $filter->setValue(['to' => 30]); $this->ds->filter([$filter]); @@ -116,7 +116,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterRangeMinMax(): void { - $filter = new FilterRange($this->grid, 'a', 'b', 'age', '-'); + $filter = new FilterRange($this->datagrid, 'a', 'b', 'age', '-'); $filter->setValue(['from' => 12, 'to' => 30]); $this->ds->filter([$filter]); @@ -135,7 +135,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterExactSearch(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['name']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name']); $filter->setExactSearch(); $filter->setValue('John Red'); @@ -146,7 +146,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterExactSearchId(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['id']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['id']); $filter->setExactSearch(); $filter->setValue(3); @@ -183,7 +183,7 @@ abstract class BaseDataSourceTest extends TestCase public function testFilterSelect(): void { - $filter = new FilterSelect($this->grid, 'a', 'b', ['John Red' => 'John Red'], 'name'); + $filter = new FilterSelect($this->datagrid, 'a', 'b', ['John Red' => 'John Red'], 'name'); $filter->setValue('John Red'); $this->ds->filter([$filter]); diff --git a/tests/Cases/DataSources/DibiFluentDataSourceTest.phpt b/tests/Cases/DataSources/DibiFluentDataSourceTest.phpt index 30409f72..297dbea3 100644 --- a/tests/Cases/DataSources/DibiFluentDataSourceTest.phpt +++ b/tests/Cases/DataSources/DibiFluentDataSourceTest.phpt @@ -22,7 +22,7 @@ final class DibiFluentDataSourceTest extends BaseDataSourceTest $this->setUpDatabase(); $this->ds = new DibiFluentDataSource($this->db->select('*')->from('users'), 'id'); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } protected function setUpDatabase(): void diff --git a/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php b/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php index 8495389a..043ada1f 100644 --- a/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php +++ b/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php @@ -17,12 +17,12 @@ public function setUp(): void { $this->ds = new DoctrineCollectionDataSource(new ArrayCollection($this->data), 'id'); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testFilterMultipleColumns(): void { - $filter = new FilterText($this->grid, 'a', 'b', ['name', 'address']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['name', 'address']); $filter->setValue('lu'); $this->ds->filter([$filter]); diff --git a/tests/Cases/DataSources/DoctrineDataSourceTest.phpt b/tests/Cases/DataSources/DoctrineDataSourceTest.phpt index 78f9a97b..8594b7e8 100644 --- a/tests/Cases/DataSources/DoctrineDataSourceTest.phpt +++ b/tests/Cases/DataSources/DoctrineDataSourceTest.phpt @@ -36,7 +36,7 @@ final class DoctrineDataSourceTest extends BaseDataSourceTest ]); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } protected function setUpDatabase(): void diff --git a/tests/Cases/DataSources/NetteDatabaseTableDataSourceTest.phpt b/tests/Cases/DataSources/NetteDatabaseTableDataSourceTest.phpt index c7d62f82..93baf289 100644 --- a/tests/Cases/DataSources/NetteDatabaseTableDataSourceTest.phpt +++ b/tests/Cases/DataSources/NetteDatabaseTableDataSourceTest.phpt @@ -24,7 +24,7 @@ final class NetteDatabaseTableDataSourceTest extends BaseDataSourceTest $this->ds = new NetteDatabaseTableDataSource($this->db->table('users'), 'id'); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } protected function setUpDatabase(): void diff --git a/tests/Cases/DataSources/NextrasDataSourceTest.phpt b/tests/Cases/DataSources/NextrasDataSourceTest.phpt index 574f90c2..30bff40a 100644 --- a/tests/Cases/DataSources/NextrasDataSourceTest.phpt +++ b/tests/Cases/DataSources/NextrasDataSourceTest.phpt @@ -42,7 +42,7 @@ final class NextrasDataSourceTest extends BaseDataSourceTest $this->ds = new NextrasDataSource($this->model->books->findAll(), 'id'); - $filter = new FilterText($this->grid, 'a', 'b', ['author.name']); + $filter = new FilterText($this->datagrid, 'a', 'b', ['author.name']); $filter->setValue('John Red'); $this->ds->filter([$filter]); @@ -55,7 +55,7 @@ final class NextrasDataSourceTest extends BaseDataSourceTest $this->ds = new NextrasDataSource($this->model->users->findAll(), 'id'); $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } protected function setUpDatabase(): void diff --git a/tests/Cases/DatagridTest.phpt b/tests/Cases/DatagridTest.phpt index b771c4a6..bdee3a58 100644 --- a/tests/Cases/DatagridTest.phpt +++ b/tests/Cases/DatagridTest.phpt @@ -16,8 +16,8 @@ final class DatagridTest extends TestCase public function testDefaultFilter(): void { $factory = new TestingDatagridFactoryRouter(); - /** @var Datagrid $grid */ - $grid = $factory->createTestingDatagrid()->getComponent('grid'); + /** @var Datagrid $datagrid */ + $grid = $factory->createTestingDatagrid()->getComponent('datagrid'); $grid->addFilterText('test', 'Test filter'); $grid->setDefaultFilter([ 'test' => 'value', @@ -33,8 +33,8 @@ final class DatagridTest extends TestCase public function testResetFilterLinkWithRememberOption(): void { $factory = new TestingDatagridFactoryRouter(); - /** @var Datagrid $grid */ - $grid = $factory->createTestingDatagrid()->getComponent('grid'); + /** @var Datagrid $datagrid */ + $grid = $factory->createTestingDatagrid()->getComponent('datagrid'); $grid->setRememberState(true); Assert::exception(function () use ($grid): void { @@ -45,8 +45,8 @@ final class DatagridTest extends TestCase public function testResetFilterLinkWithNoRememberOption(): void { $factory = new TestingDatagridFactoryRouter(); - /** @var Datagrid $grid */ - $grid = $factory->createTestingDatagrid()->getComponent('grid'); + /** @var Datagrid $datagrid */ + $grid = $factory->createTestingDatagrid()->getComponent('datagrid'); $grid->setRememberState(false); Assert::exception(function () use ($grid): void { diff --git a/tests/Cases/EnumTest.phpt b/tests/Cases/EnumTest.phpt index 2787dcad..7669e770 100644 --- a/tests/Cases/EnumTest.phpt +++ b/tests/Cases/EnumTest.phpt @@ -20,18 +20,18 @@ use Tester\TestCase; final class EnumTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testArrayWithEnum(): void { $entity = ['id' => 20, 'name' => 'John Doe', 'age' => 23, 'gender' => GenderEnum::Male]; - $row = new Row($this->grid, $entity, 'id'); + $row = new Row($this->datagrid, $entity, 'id'); Assert::same(GenderEnum::Male->value, $row->getValue('gender')); } @@ -39,7 +39,7 @@ final class EnumTest extends TestCase public function testDoctrineEntityWithEnum(): void { $entity = new TestingDDatagridEntity(['id' => 20, 'name' => 'John Doe', 'age' => 23, 'gender' => GenderEnum::Male]); - $row = new Row($this->grid, $entity, 'id'); + $row = new Row($this->datagrid, $entity, 'id'); Assert::same(GenderEnum::Male->value, $row->getValue('gender')); } diff --git a/tests/Cases/ExportTest.phpt b/tests/Cases/ExportTest.phpt index 48321175..84fa9a3a 100644 --- a/tests/Cases/ExportTest.phpt +++ b/tests/Cases/ExportTest.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; final class ExportTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; private array $data = [ [ @@ -42,7 +42,7 @@ final class ExportTest extends TestCase public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testExportNotFiltered(): void @@ -52,17 +52,17 @@ final class ExportTest extends TestCase Assert::same($data, $source); }; - $this->grid->addExportCallback('Export', $callback); + $this->datagrid->addExportCallback('Export', $callback); $trigger = function (): void { - $this->grid->handleExport(1); + $this->datagrid->handleExport(1); }; Assert::exception($trigger, 'Contributte\Datagrid\Exception\DatagridException', 'You have to set a data source first.'); - $this->grid->setDataSource($this->data); + $this->datagrid->setDataSource($this->data); - $this->grid->handleExport(1); + $this->datagrid->handleExport(1); } public function testExportFiltered(): void @@ -72,20 +72,20 @@ final class ExportTest extends TestCase Assert::same($data, $source); }; - $this->grid->addExportCallback('Export', $callback, true); + $this->datagrid->addExportCallback('Export', $callback, true); - $this->grid->addFilterText('name', 'Name'); + $this->datagrid->addFilterText('name', 'Name'); - $this->grid; + $this->datagrid; $trigger = function (): void { - $this->grid->handleExport(1); + $this->datagrid->handleExport(1); }; Assert::exception($trigger, 'Contributte\Datagrid\Exception\DatagridException', 'You have to set a data source first.'); - $this->grid->setDataSource($this->data); + $this->datagrid->setDataSource($this->data); - $this->grid->handleExport(1); + $this->datagrid->handleExport(1); } } diff --git a/tests/Cases/FilterTest.phpt b/tests/Cases/FilterTest.phpt index 7f6c0e02..685a5b1f 100644 --- a/tests/Cases/FilterTest.phpt +++ b/tests/Cases/FilterTest.phpt @@ -16,8 +16,8 @@ final class FilterTest extends TestCase public function testFilterSubmit(): void { $factory = new TestingDatagridFactoryRouter(); - /** @var Datagrid $grid */ - $grid = $factory->createTestingDatagrid()->getComponent('grid'); + /** @var Datagrid $datagrid */ + $grid = $factory->createTestingDatagrid()->getComponent('datagrid'); $filterForm = $grid->createComponentFilter(); Assert::exception(function () use ($grid, $filterForm): void { diff --git a/tests/Cases/ItemsPerPageTest.phpt b/tests/Cases/ItemsPerPageTest.phpt index 1db7712d..a7a0c883 100644 --- a/tests/Cases/ItemsPerPageTest.phpt +++ b/tests/Cases/ItemsPerPageTest.phpt @@ -21,34 +21,34 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; class ItemsPerPageTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testGetPerPage(): void { - $this->grid->setItemsPerPageList([10, 20, 50], false); + $this->datagrid->setItemsPerPageList([10, 20, 50], false); - $this->grid->perPage = 20; - Assert::same(20, $this->grid->getPerPage()); + $this->datagrid->perPage = 20; + Assert::same(20, $this->datagrid->getPerPage()); - $this->grid->perPage = 'all'; - Assert::same(10, $this->grid->getPerPage()); + $this->datagrid->perPage = 'all'; + Assert::same(10, $this->datagrid->getPerPage()); } public function testGetPerPageAll(): void { - $this->grid->setItemsPerPageList([10, 20, 50], true); + $this->datagrid->setItemsPerPageList([10, 20, 50], true); - $this->grid->perPage = 20; - Assert::same(20, $this->grid->getPerPage()); + $this->datagrid->perPage = 20; + Assert::same(20, $this->datagrid->getPerPage()); - $this->grid->perPage = 'all'; - Assert::same('all', $this->grid->getPerPage()); + $this->datagrid->perPage = 'all'; + Assert::same('all', $this->datagrid->getPerPage()); } public function testGetPerPageAllTranslated(): void @@ -56,15 +56,15 @@ class ItemsPerPageTest extends TestCase $translator = new SimpleTranslator([ 'contributte_datagrid.all' => 'všechny', ]); - $this->grid->setTranslator($translator); + $this->datagrid->setTranslator($translator); - $this->grid->setItemsPerPageList([10, 20, 50], true); + $this->datagrid->setItemsPerPageList([10, 20, 50], true); - $this->grid->perPage = 20; - Assert::same(20, $this->grid->getPerPage()); + $this->datagrid->perPage = 20; + Assert::same(20, $this->datagrid->getPerPage()); - $this->grid->perPage = 'all'; - Assert::same('all', $this->grid->getPerPage()); + $this->datagrid->perPage = 'all'; + Assert::same('all', $this->datagrid->getPerPage()); } } diff --git a/tests/Cases/OnColumnAddCallbackTest.phpt b/tests/Cases/OnColumnAddCallbackTest.phpt index a3db5a54..1244d6cb 100644 --- a/tests/Cases/OnColumnAddCallbackTest.phpt +++ b/tests/Cases/OnColumnAddCallbackTest.phpt @@ -21,25 +21,25 @@ require __DIR__ . '/../Files/TestingDatagridFactory.php'; class OnColumnAddCallbackTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testSetSortable(): void { - $this->grid->onColumnAdd[] = function ($key, Column $column): void { + $this->datagrid->onColumnAdd[] = function ($key, Column $column): void { $column->setSortable(); }; - $columnText = $this->grid->addColumnText('text', 'textName'); - $columnNumber = $this->grid->addColumnNumber('number', 'numberName'); - $columnDateTime = $this->grid->addColumnDateTime('dateTime', 'dateTimeName'); + $columnText = $this->datagrid->addColumnText('text', 'textName'); + $columnNumber = $this->datagrid->addColumnNumber('number', 'numberName'); + $columnDateTime = $this->datagrid->addColumnDateTime('dateTime', 'dateTimeName'); - $columnTextNotSortable = $this->grid->addColumnText('textNotSortable', 'textName') + $columnTextNotSortable = $this->datagrid->addColumnText('textNotSortable', 'textName') ->setSortable(false); Assert::true($columnText->isSortable()); diff --git a/tests/Cases/RowTest.phpt b/tests/Cases/RowTest.phpt index 338e1ff9..e138a3c9 100644 --- a/tests/Cases/RowTest.phpt +++ b/tests/Cases/RowTest.phpt @@ -17,12 +17,12 @@ use Tester\TestCase; final class RowTest extends TestCase { - private Datagrid $grid; + private Datagrid $datagrid; public function setUp(): void { $factory = new TestingDatagridFactory(); - $this->grid = $factory->createTestingDatagrid(); + $this->datagrid = $factory->createTestingDatagrid(); } public function testControl(): void @@ -32,7 +32,7 @@ final class RowTest extends TestCase $row->addClass('bg-warning'); }; - $row = new Row($this->grid, $item, 'id'); + $row = new Row($this->datagrid, $item, 'id'); $callback($item, $row->getControl()); Assert::same(20, $row->getId()); @@ -43,7 +43,7 @@ final class RowTest extends TestCase { $item = ['id' => 20, 'name' => 'John Doe']; - $row = new Row($this->grid, $item, 'id'); + $row = new Row($this->datagrid, $item, 'id'); Assert::same(20, $row->getId()); Assert::same('John Doe', $row->getValue('name')); @@ -53,7 +53,7 @@ final class RowTest extends TestCase { $item = (object) ['id' => 20, 'name' => 'John Doe']; - $row = new Row($this->grid, $item, 'id'); + $row = new Row($this->datagrid, $item, 'id'); Assert::same(20, $row->getId()); } @@ -65,7 +65,7 @@ final class RowTest extends TestCase $entity->setPartner($entity2); - $row = new Row($this->grid, $entity, 'id'); + $row = new Row($this->datagrid, $entity, 'id'); Assert::same(20, $row->getId()); Assert::same('John Doe', $row->getValue('name')); @@ -79,7 +79,7 @@ final class RowTest extends TestCase $entity->id = '978-80-257-1309-9'; $entity->pageCount = 42; - $row = new Row($this->grid, $entity, 'id'); + $row = new Row($this->datagrid, $entity, 'id'); Assert::same('978-80-257-1309-9', $row->getValue('id')); Assert::same(42, $row->getValue('pageCount')); diff --git a/tests/Files/ExportTestingPresenter.php b/tests/Files/ExportTestingPresenter.php index d0a992bc..c2c02a46 100644 --- a/tests/Files/ExportTestingPresenter.php +++ b/tests/Files/ExportTestingPresenter.php @@ -8,7 +8,7 @@ final class ExportTestingPresenter extends Presenter { - protected function createComponentGrid(string $name): Datagrid + protected function createComponentDatagrid(string $name): Datagrid { $grid = new Datagrid(null, $name); $grid->addExportCsv('export', 'export.csv'); diff --git a/tests/Files/TestGridControl.php b/tests/Files/TestGridControl.php index 659d6e81..65baff58 100644 --- a/tests/Files/TestGridControl.php +++ b/tests/Files/TestGridControl.php @@ -8,7 +8,7 @@ class TestGridControl extends Control { - public function createComponentGrid(): Datagrid + public function createComponentDatagrid(): Datagrid { return new Datagrid(); } diff --git a/tests/Files/TestPresenter.php b/tests/Files/TestPresenter.php index 148e9ee2..40f31c0c 100644 --- a/tests/Files/TestPresenter.php +++ b/tests/Files/TestPresenter.php @@ -9,7 +9,7 @@ final class TestPresenter extends Presenter { - protected function createComponentGrid(): TestGridControl + protected function createComponentDatagrid(): TestGridControl { return new TestGridControl(); } diff --git a/tests/Files/TestingDatagridFactory.php b/tests/Files/TestingDatagridFactory.php index e200e312..4835c592 100644 --- a/tests/Files/TestingDatagridFactory.php +++ b/tests/Files/TestingDatagridFactory.php @@ -26,7 +26,7 @@ public function createTestingDatagrid(string $presenterName = 'Testing'): Datagr $presenter->injectPrimary($request, $response, $presenterFactory, null, $session); - return $presenter->getComponent('grid'); + return $presenter->getComponent('datagrid'); } } diff --git a/tests/Files/TestingDatagridFactoryRouter.php b/tests/Files/TestingDatagridFactoryRouter.php index 197ea528..af7a8b60 100644 --- a/tests/Files/TestingDatagridFactoryRouter.php +++ b/tests/Files/TestingDatagridFactoryRouter.php @@ -32,7 +32,7 @@ public function createTestingDatagrid(): ?IComponent $presenter->run(new Request('Test', 'GET', [])); - return $presenter->getComponent('grid'); + return $presenter->getComponent('datagrid'); } } diff --git a/tests/Files/TestingPresenter.php b/tests/Files/TestingPresenter.php index 3b757160..1d32877e 100644 --- a/tests/Files/TestingPresenter.php +++ b/tests/Files/TestingPresenter.php @@ -23,7 +23,7 @@ public function link(string $destination, $args = []): string return $destination . '?' . http_build_query($args); } - protected function createComponentGrid(string $name): Datagrid + protected function createComponentDatagrid(string $name): Datagrid { return new Datagrid($this, $name); }