Problem/Motivation

ControllerBase has a convenience method for generating a RedirectResponse.
This would be useful for FormBase and others, which are already using UrlGeneratorTrait.

Proposed resolution

Move redirect() to UrlGeneratorTrait

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
Related issues: +#2340251: Remove most remaining url() calls
FileSize
6.3 KB

I've converted the cases that already used $this->url(), leaving the url() calls for #2340251: Remove most remaining url() calls.

dawehner’s picture

I can haz tests?

tim.plunkett’s picture

FileSize
7.66 KB
1.38 KB

Ask and ye shall receive.

znerol’s picture

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Looks great.

znerol’s picture

From the original issue I linked in #4.

redirect() belongs only in the Controller, as you have to return a redirect object; it's not just for formatting a string. Triggering a redirect in most non-Controller places is a code smell.

Did something change in the meantime such that it is now justifiable to add redirect() to the trait?

tim.plunkett’s picture

We still need them in Forms.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4014b74 and pushed to 8.0.x. Thanks!

Yep forms need this.

  • alexpott committed 4014b74 on 8.0.x
    Issue #2344491 by tim.plunkett: Move ControllerBase::redirect() to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.