Returns the object used to build the form.
\Symfony\Component\HttpFoundation\Request $request: The request using this form.
string $form_arg: Either a class name or a service ID.
\Drupal\Core\Form\FormInterface The form object to use.
protected function getFormObject(Request $request, $form_arg) {
// If this is a class, instantiate it.
if (class_exists($form_arg)) {
if (in_array('Drupal\\Core\\Controller\\ControllerInterface', class_implements($form_arg))) {
return $form_arg::create($this->container);
}
return new $form_arg();
}
// Otherwise, it is a service.
return $this->container
->get($form_arg);
}