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
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.txt | 1.2 KB | tim.plunkett |
#7 | controller-2166863-7.patch | 2.47 KB | tim.plunkett |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedComment #2
pwolanin CreditAttribution: pwolanin commentedComment #3
dawehnerWe now have a test class for \Drupal, so we maybe better extend that one.
Comment #4
dawehner1: 2166863-1.patch queued for re-testing.
Comment #5
dawehnerMy comment was full of BS, we deal with ControllerBase here, which we simply test by usage.
Comment #6
xjmThis isn't a feature. :)
Comment #7
tim.plunkettMissing a line in the @var, and there were two other calls in a ControllerBase subclass.
Leaving RTBC.
Comment #8
webchickCommitted and pushed to 8.x. Thanks!