Commit 9de73791 authored by webchick's avatar webchick

Issue #2166863 by tim.plunkett, pwolanin: Add a formBuilder() method to ControllerBase.

parent 75c03922
......@@ -93,6 +93,13 @@ abstract class ControllerBase {
*/
protected $moduleHandler;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* Retrieves the entity manager service.
*
......@@ -188,6 +195,18 @@ protected function moduleHandler() {
return $this->moduleHandler;
}
/**
* Returns the form builder service.
*
* @return \Drupal\Core\Form\FormBuilderInterface
*/
protected function formBuilder() {
if (!$this->formBuilder) {
$this->formBuilder = $this->container()->get('form_builder');
}
return $this->formBuilder;
}
/**
* Returns the URL generator service.
*
......
......@@ -49,8 +49,8 @@ public function checkTranslation() {
*/
public function translatePage() {
return array(
'filter' => drupal_get_form('Drupal\locale\Form\TranslateFilterForm'),
'form' => drupal_get_form('Drupal\locale\Form\TranslateEditForm'),
'filter' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateFilterForm'),
'form' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateEditForm'),
);
}
......
......@@ -38,7 +38,7 @@ public function userPage(Request $request) {
else {
// Sets the proper request.
// @todo Remove when the request object is synchronized.
$form_builder = \Drupal::formBuilder();
$form_builder = $this->formBuilder();
$form_builder->setRequest($request);
$response = $form_builder->getForm('Drupal\user\Form\UserLoginForm');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment