Create a "setDestination" method on \Drupal\Core\Url to make it easier to set the destination

Created on 14 February 2018, about 7 years ago
Updated 21 April 2025, 4 days ago

Problem/Motivation

Currently to the set the destination to the current page,very common, you have to do:
$url->setOption('query', \Drupal::destination()->getAsArray())
To set to another path you have to
$url->setOption('query', ['destination' => 'other/path')

It should be easier.

Proposed resolution

Add
\Drupal\Core\Url::setDestination()
Which will default to current path if known is set.

Remaining tasks

do it

User interface changes

None

API changes

New method

Data model changes

None

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component

base system

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024