From 6b42d402cf6f5e4b39fdb6f15dc56d40fa9a064e Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 19 Dec 2020 19:31:24 +0100 Subject: [PATCH] Remove public access for getFieldValue --- UPGRADE-3.x.md | 4 ++++ src/Admin/BaseFieldDescription.php | 10 ++++++++++ src/Admin/FieldDescriptionInterface.php | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/UPGRADE-3.x.md b/UPGRADE-3.x.md index fb3181bda6..813b48baa0 100644 --- a/UPGRADE-3.x.md +++ b/UPGRADE-3.x.md @@ -4,6 +4,10 @@ UPGRADE 3.x UPGRADE FROM 3.xx to 3.xx ========================= +### Deprecated `FieldDescriptionInterface::getFieldValue()` + +`BaseFieldDescription::getFieldValue()` will become protected. + ### `RouteCollection` now implements `RouteCollectionInterface` In 4.0, `AbstractAdmin::configureRoutes` and `AdminExtensionInterface::configureRoutes` will receive a diff --git a/src/Admin/BaseFieldDescription.php b/src/Admin/BaseFieldDescription.php index f9672e4e01..431babffa8 100644 --- a/src/Admin/BaseFieldDescription.php +++ b/src/Admin/BaseFieldDescription.php @@ -381,6 +381,16 @@ public function hasAssociationAdmin() return null !== $this->associationAdmin; } + /** + * NEXT_MAJOR: Change the visibility to protected. + * + * @param object|null $object + * @param string $fieldName + * + * @throws NoValueException + * + * @return mixed + */ public function getFieldValue($object, $fieldName) { if ($this->isVirtual() || null === $object) { diff --git a/src/Admin/FieldDescriptionInterface.php b/src/Admin/FieldDescriptionInterface.php index 698bd88b9b..bac91a7a0a 100644 --- a/src/Admin/FieldDescriptionInterface.php +++ b/src/Admin/FieldDescriptionInterface.php @@ -13,6 +13,8 @@ namespace Sonata\AdminBundle\Admin; +use Sonata\AdminBundle\Exception\NoValueException; + /** * @author Thomas Rabaix * @@ -228,7 +230,9 @@ public function isIdentifier(); * * @param object $object * - * @return bool|mixed + * @throws NoValueException if the value cannot be determined + * + * @return mixed */ public function getValue($object); @@ -314,6 +318,10 @@ public function getSortFieldMapping(); public function getSortParentAssociationMapping(); /** + * NEXT_MAJOR: Remove this method from the interface. + * + * @deprecated since sonata-project/admin-bundle 3.x, to be removed in 4.0. + * * @param object|null $object * @param string $fieldName *