From 384741e71c3a292a087f2db71cd7281c10a4ce19 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 4 Jan 2025 20:29:30 +0100 Subject: [PATCH] Deprecate the AdminContext:getReferrer() method --- UPGRADE.md | 18 ++++++++++++++++++ src/Context/AdminContext.php | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index b80c52fad4..7fcac1a2ce 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -117,6 +117,24 @@ that page title: } } +EasyAdmin 4.8.11 +---------------- + +EasyAdmin URLs no longer include the `referrer` query parameter, and the +`AdminContext:getReferrer()` method is deprecated. + +This change is part of the long-term project to simplify URLs, with the goal of +using pretty URLs in the future. If you still need to access the referrer, you +can retrieve it from the HTTP headers provided by browsers: + +```php +// Before +return $this->redirect($context->getReferrer()); + +// After +return $this->redirect($context->getRequest()->headers->get('referer')); +``` + EasyAdmin 4.8.0 --------------- diff --git a/src/Context/AdminContext.php b/src/Context/AdminContext.php index 6dacad31bd..cce3e081e4 100644 --- a/src/Context/AdminContext.php +++ b/src/Context/AdminContext.php @@ -70,6 +70,13 @@ public function getRequest(): Request public function getReferrer(): ?string { + trigger_deprecation( + 'easycorp/easyadmin-bundle', + '4.8.11', + 'EasyAdmin URLs no longer include the referrer URL. If you still need it, you can get the referrer provided by browsers via $context->getRequest()->headers->get(\'referer\').', + __METHOD__, + ); + $referrer = $this->request->query->get(EA::REFERRER); return '' !== $referrer ? $referrer : null;