diff --git a/docs/guide/filters.md b/docs/guide/filters.md index d9bb6fb2d..86ad397b0 100644 --- a/docs/guide/filters.md +++ b/docs/guide/filters.md @@ -243,7 +243,7 @@ In order to make this feature work, since filters are generalized, you'll need t ## Drop filters depending on functional data -Sometimes you may want to hide a filter to the user depending on the actual data, or on other filters values. This can be achieved by using the `dropFilter()` method in your EntityList class, typically in the `getListData()` method. +Sometimes you may want to hide a filter to the user depending on the actual data, or on other filters values. This can be achieved by using the `useFilter()` method in your EntityList class, typically in the `getListData()` method. ```php class OrderEntityList extends SharpEntityList @@ -262,7 +262,7 @@ class OrderEntityList extends SharpEntityList { if ($this->queryParams->filterFor(PaymentMethodFilter::class) !== 'online') { // No need to show the OnlinePaymentProviderFilter - $this->dropFilter(OnlinePaymentProviderFilter::class); + $this->hideFilter(OnlinePaymentProviderFilter::class); } // ... diff --git a/docs/guide/reordering-instances.md b/docs/guide/reordering-instances.md index 2dc90c44c..0227e1de3 100644 --- a/docs/guide/reordering-instances.md +++ b/docs/guide/reordering-instances.md @@ -36,7 +36,7 @@ Then, in your Entity List you have to configure your reorder handler: ```php class PageEntityList extends SharpEntityList { - // [...] + // ... public function buildListConfig() { @@ -55,7 +55,7 @@ Note that you can also pass a ReorderHandler classname, or an anonymous class th The reorder action depends on the `reorder` permission. You can define it in the [Entity Policy](entity-authorizations.md): -Sometimes you may need to restrict the reorder action depending on the actual data, or on some filters values. This can be achieved by using the `forbidReorder()` method in your EntityList class, typically in the `getListData()` method. +Sometimes you may need to restrict the reorder action depending on the actual data, or on some filters values. This can be achieved by using the `disableReorder()` method in your EntityList class, typically in the `getListData()` method. ```php class PostEntityList extends SharpEntityList @@ -70,7 +70,7 @@ class PostEntityList extends SharpEntityList public function getListData(): array|Arrayable { // We can’t reorder if there is a search - $this->forbidReorder($this->queryParams->hasSearch()); + $this->disableReorder($this->queryParams->hasSearch()); // ... } diff --git a/src/EntityList/SharpEntityList.php b/src/EntityList/SharpEntityList.php index 118c5ba07..fb6e71e6d 100644 --- a/src/EntityList/SharpEntityList.php +++ b/src/EntityList/SharpEntityList.php @@ -29,7 +29,7 @@ abstract class SharpEntityList protected ?string $multiformAttribute = null; protected bool $searchable = false; protected ?ReorderHandler $reorderHandler = null; - private bool $forbidsReorder = false; + private bool $disabledReorder = false; protected ?string $defaultSort = null; protected ?string $defaultSortDir = null; protected bool $deleteHidden = false; @@ -107,7 +107,7 @@ final public function listConfig(bool $hasShowPage = false): array 'instanceIdAttribute' => $this->instanceIdAttribute, 'multiformAttribute' => $this->multiformAttribute, 'searchable' => $this->searchable, - 'reorderable' => ! is_null($this->reorderHandler) && ! $this->forbidsReorder, + 'reorderable' => ! is_null($this->reorderHandler) && ! $this->disabledReorder, 'defaultSort' => $this->defaultSort, 'defaultSortDir' => $this->defaultSortDir, 'hasShowPage' => $hasShowPage, @@ -195,9 +195,9 @@ final protected function getDataKeys(): array ->all(); } - final protected function forbidReorder(bool $forbidReorder = true): void + final protected function disableReorder(bool $disableReorder = true): void { - $this->forbidsReorder = $forbidReorder; + $this->disabledReorder = $disableReorder; } /** diff --git a/src/Utils/Filters/HandleFilters.php b/src/Utils/Filters/HandleFilters.php index f9cdb58dd..c684a6477 100644 --- a/src/Utils/Filters/HandleFilters.php +++ b/src/Utils/Filters/HandleFilters.php @@ -20,7 +20,7 @@ final public function filterContainer(): FilterContainer /** * @internal */ - final public function dropFilter(string $filterFullClassNameOrKey): void + final public function hideFilter(string $filterFullClassNameOrKey): void { $this->filterContainer()->excludeFilter($filterFullClassNameOrKey); } diff --git a/tests/Unit/EntityList/SharpEntityListFilterTest.php b/tests/Unit/EntityList/SharpEntityListFilterTest.php index 7ee0bb2dd..5e534c950 100644 --- a/tests/Unit/EntityList/SharpEntityListFilterTest.php +++ b/tests/Unit/EntityList/SharpEntityListFilterTest.php @@ -532,7 +532,7 @@ public function values(): array public function getListData(): array { - $this->dropFilter('test'); + $this->hideFilter('test'); return []; } diff --git a/tests/Unit/EntityList/SharpEntityListTest.php b/tests/Unit/EntityList/SharpEntityListTest.php index 2d9bdecc3..7dd1b022b 100644 --- a/tests/Unit/EntityList/SharpEntityListTest.php +++ b/tests/Unit/EntityList/SharpEntityListTest.php @@ -296,7 +296,7 @@ public function reorder(array $ids): void {} ->and($list->reorderHandler())->toBeInstanceOf(ReorderHandler::class); }); -it('allows to borbid a configured reorder handler', function () { +it('allows to disable a configured reorder handler', function () { $list = new class() extends FakeSharpEntityList { public function buildListConfig(): void @@ -309,7 +309,7 @@ public function reorder(array $ids): void {} public function getListData(): array|Arrayable { - $this->forbidReorder(); + $this->disableReorder(); return []; }