From b546073a0d0c97b55d8f88dc572fac66fb5d9953 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 16 Aug 2020 14:01:45 +0200 Subject: [PATCH] Deprecate getSingleScalarResult method --- UPGRADE-3.x.md | 4 ++++ src/Datagrid/ProxyQueryInterface.php | 4 ++++ tests/App/Datagrid/ProxyQuery.php | 29 ++++++++++++++++++---------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/UPGRADE-3.x.md b/UPGRADE-3.x.md index 892a122d77..fed7c22baa 100644 --- a/UPGRADE-3.x.md +++ b/UPGRADE-3.x.md @@ -4,6 +4,10 @@ UPGRADE 3.x UPGRADE FROM 3.x to 3.x ======================= +## Deprecated `Sonata\AdminBundle\Datagrid\ProxyQueryInterface::getSingleScalarResult` + +Use `Sonata\AdminBundle\Datagrid\ProxyQueryInterface::execute` instead. + ## The following templates have been deprecated - `src/Resources/views/CRUD/base_filter_field.html.twig` diff --git a/src/Datagrid/ProxyQueryInterface.php b/src/Datagrid/ProxyQueryInterface.php index 1e673849a4..d39fdf624f 100644 --- a/src/Datagrid/ProxyQueryInterface.php +++ b/src/Datagrid/ProxyQueryInterface.php @@ -61,6 +61,10 @@ public function setSortOrder($sortOrder); public function getSortOrder(); /** + * NEXT_MAJOR: Remove this method. + * + * @deprecated since sonata-project/admin-bundle 3.x, to be removed in 4.0. + * * @return mixed */ public function getSingleScalarResult(); diff --git a/tests/App/Datagrid/ProxyQuery.php b/tests/App/Datagrid/ProxyQuery.php index 71d788a959..f6530f9fb9 100644 --- a/tests/App/Datagrid/ProxyQuery.php +++ b/tests/App/Datagrid/ProxyQuery.php @@ -23,55 +23,64 @@ public function __call($name, $args) public function execute(array $params = [], $hydrationMode = null) { + throw new \BadMethodCallException('Not implemented.'); } - public function setSortBy($parentAssociationMappings, $fieldMapping): void + public function setSortBy($parentAssociationMappings, $fieldMapping): ProxyQueryInterface { + throw new \BadMethodCallException('Not implemented.'); } - public function getSortBy() + public function getSortBy(): string { return 'e.id'; } - public function setSortOrder($sortOrder): void + public function setSortOrder($sortOrder): ProxyQueryInterface { + throw new \BadMethodCallException('Not implemented.'); } - public function getSortOrder() + public function getSortOrder(): string { return 'ASC'; } + /** + * NEXT_MAJOR: Remove this method. + */ public function getSingleScalarResult() { return 0; } - public function setFirstResult($firstResult): void + public function setFirstResult($firstResult): ProxyQueryInterface { + throw new \BadMethodCallException('Not implemented.'); } - public function getFirstResult() + public function getFirstResult(): ?int { throw new \BadMethodCallException('Not implemented.'); } - public function setMaxResults($maxResults): void + public function setMaxResults($maxResults): ProxyQueryInterface { + throw new \BadMethodCallException('Not implemented.'); } - public function getMaxResults() + public function getMaxResults(): ?int { return 1; } - public function getUniqueParameterId() + public function getUniqueParameterId(): int { return 1; } - public function entityJoin(array $associationMappings): void + public function entityJoin(array $associationMappings): array { + throw new \BadMethodCallException('Not implemented.'); } }