Updated: Comment #N

Problem/Motivation

Often one wants to have one or several forms as part of a rendered page. However, it's more work than it should be to inject the form_builder service into a _content controller class.

In addition, while \Drupal\Core\Controller\ControllerBase has a copy of the container, it's planned to make that private and currently is NOT supposed to be invoked directly like

$form_builder = $this->container()->get('form_builder');

Proposed resolution

Add a protected formBuilder() method to \Drupal\Core\Controller\ControllerBase similar to other methods that expose services.

Remaining tasks

Patch/test

User interface changes

N/A

API changes

Add a method to \Drupal\Core\Controller\ControllerBase

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Status: Active » Needs review
FileSize
1.66 KB
pwolanin’s picture

Issue summary: View changes
dawehner’s picture

We now have a test class for \Drupal, so we maybe better extend that one.

dawehner’s picture

1: 2166863-1.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

My comment was full of BS, we deal with ControllerBase here, which we simply test by usage.

xjm’s picture

Category: Feature request » Task
Issue tags: +DX (Developer Experience), +Quick fix

This isn't a feature. :)

tim.plunkett’s picture

FileSize
2.47 KB
1.2 KB

Missing a line in the @var, and there were two other calls in a ControllerBase subclass.

Leaving RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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