Skip to content

Commit

Permalink
bug #6684 Deprecate the AdminContext:getReferrer() method (javieregui…
Browse files Browse the repository at this point in the history
…luz)

This PR was merged into the 4.x branch.

Discussion
----------

Deprecate the AdminContext:getReferrer() method

Fixes #6115.

This was deprecated in practice a long time ago, when we removed the `referrer` parameter from URLs in #6105. But, we didn't formally deprecate the associated method in `AdminContext:getReferrer()`. Let's do that now.

Commits
-------

384741e Deprecate the AdminContext:getReferrer() method
  • Loading branch information
javiereguiluz committed Jan 4, 2025
2 parents faa7730 + 384741e commit 11c0600
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------

Expand Down
7 changes: 7 additions & 0 deletions src/Context/AdminContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 11c0600

Please sign in to comment.