Skip to content

Commit

Permalink
Deprecate DatagridManagerInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Oct 19, 2020
1 parent e2b61ae commit 6864e7a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 6 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
UPGRADE 3.x
===========

### Deprecated `Sonata\AdminBundle\Model\DatagridManagerInterface` interface.

This interface has been deprecated without replacement.

`ModelManager::getDefaultSortValues()` won't be use anymore.

### Deprecated not configuring `acl_user_manager` and using ACL security handler when `friendsofsymfony/user-bundle` is installed.

If you are using `friendsofsymfony/user-bundle` and using ACL security handler, you MUST explicitly configure the `acl_user_manager`.
Expand Down
10 changes: 6 additions & 4 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,10 @@ public function preBatchAction($actionName, ProxyQueryInterface $query, array &$
public function getFilterParameters()
{
$parameters = array_merge(
$this->getModelManager()->getDefaultSortValues($this->getClass()),
$this->getModelManager()->getDefaultSortValues($this->getClass()), // NEXT_MAJOR: Remove this line.
$this->datagridValues, // NEXT_MAJOR: Remove this line.
$this->getDefaultSortValues(),
$this->getDefaultFilterValues()
$this->getDefaultFilterValues(),
);

// build the values array
Expand Down Expand Up @@ -1699,7 +1699,7 @@ public function getMaxPerPage()
{
// NEXT_MAJOR: Remove this line and uncomment the following.
return $this->maxPerPage;
// $sortValues = $this->getModelManager()->getDefaultSortValues($this->class);
// $sortValues = $this->getDefaultSortValues();

// return $sortValues['_per_page'] ?? 25;
}
Expand Down Expand Up @@ -2918,7 +2918,7 @@ public function getPerPageOptions()
{
// NEXT_MAJOR: Remove this line and uncomment the following
return $this->perPageOptions;
// $perPageOptions = $this->getModelManager()->getDefaultPerPageOptions($this->class);
// $perPageOptions = [10, 25, 50, 100, 250];
// $perPageOptions[] = $this->getMaxPerPage();
//
// $perPageOptions = array_unique($perPageOptions);
Expand Down Expand Up @@ -3312,7 +3312,9 @@ protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterfa
*/
final protected function getDefaultSortValues(): array
{
// NEXT_MAJOR: Use the next line instead.
$defaultSortValues = [];
// $defaultSortValues = ['_page' => 1, '_per_page' => 25];

$this->configureDefaultSortValues($defaultSortValues);

Expand Down
10 changes: 2 additions & 8 deletions src/Model/DatagridManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/**
* A datagrid manager is a bridge between the model classes and the admin datagrid functionality.
*
* NEXT_MAJOR: Remove this interface
*
* @method array getDefaultPerPageOptions(string $class)
*/
interface DatagridManagerInterface
Expand All @@ -28,12 +30,4 @@ interface DatagridManagerInterface
* @return array<string, int|string>
*/
public function getDefaultSortValues($class);

// NEXT_MAJOR: Uncomment the following lines.
// /**
// * Return all the allowed _per_page values.
// *
// * @return array<int>
// */
// public function getDefaultPerPageOptions(string $class): array;
}

0 comments on commit 6864e7a

Please sign in to comment.