From 8885b94bcdd7bcd97e167e28c6a30c2c5875ac97 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 5 Oct 2020 21:06:52 +0200 Subject: [PATCH] Deprecate DatagridManagerInterface --- UPGRADE-3.x.md | 6 ++++++ src/Admin/AbstractAdmin.php | 8 +++++--- src/Model/DatagridManagerInterface.php | 10 ++-------- src/Model/ModelManagerInterface.php | 2 ++ tests/App/Model/ModelManager.php | 6 ++++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/UPGRADE-3.x.md b/UPGRADE-3.x.md index 4065ea8ae9e..85b2656416e 100644 --- a/UPGRADE-3.x.md +++ b/UPGRADE-3.x.md @@ -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. + UPGRADE FROM 3.77 to 3.78 ========================= diff --git a/src/Admin/AbstractAdmin.php b/src/Admin/AbstractAdmin.php index 6a4a8ac931a..be83a902ba9 100644 --- a/src/Admin/AbstractAdmin.php +++ b/src/Admin/AbstractAdmin.php @@ -830,7 +830,7 @@ 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() @@ -1713,7 +1713,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; } @@ -2932,7 +2932,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); @@ -3326,7 +3326,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); diff --git a/src/Model/DatagridManagerInterface.php b/src/Model/DatagridManagerInterface.php index fae7a9ff887..df9655b94ec 100644 --- a/src/Model/DatagridManagerInterface.php +++ b/src/Model/DatagridManagerInterface.php @@ -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 @@ -28,12 +30,4 @@ interface DatagridManagerInterface * @return array */ public function getDefaultSortValues($class); - -// NEXT_MAJOR: Uncomment the following lines. -// /** -// * Return all the allowed _per_page values. -// * -// * @return array -// */ -// public function getDefaultPerPageOptions(string $class): array; } diff --git a/src/Model/ModelManagerInterface.php b/src/Model/ModelManagerInterface.php index 37199ae402e..112468425e3 100644 --- a/src/Model/ModelManagerInterface.php +++ b/src/Model/ModelManagerInterface.php @@ -20,6 +20,8 @@ use Sonata\Exporter\Source\SourceIteratorInterface; /** + * NEXT_MAJOR: Stop to extend DatagridManagerInterface. + * * A model manager is a bridge between the model classes and the admin functionality. * * @method bool supportsQuery(object $query) diff --git a/tests/App/Model/ModelManager.php b/tests/App/Model/ModelManager.php index 0f2eb3fc9fe..b0e739a587a 100644 --- a/tests/App/Model/ModelManager.php +++ b/tests/App/Model/ModelManager.php @@ -167,11 +167,17 @@ public function getSortParameters(FieldDescriptionInterface $fieldDescription, D return []; } + /** + * NEXT_MAJOR: Remove this method. + */ public function getDefaultSortValues($class) { return []; } + /** + * NEXT_MAJOR: Remove this method. + */ public function getDefaultPerPageOptions(string $class): array { return [];