HtmlFormController.php in Drupal 9
File
core/lib/Drupal/Core/Controller/HtmlFormController.php
View source
<?php
namespace Drupal\Core\Controller;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
class HtmlFormController extends FormController {
protected $classResolver;
public function __construct(ArgumentResolverInterface $argument_resolver, FormBuilderInterface $form_builder, ClassResolverInterface $class_resolver) {
parent::__construct($argument_resolver, $form_builder);
$this->classResolver = $class_resolver;
}
protected function getFormArgument(RouteMatchInterface $route_match) {
return $route_match
->getRouteObject()
->getDefault('_form');
}
protected function getFormObject(RouteMatchInterface $route_match, $form_arg) {
return $this->classResolver
->getInstanceFromDefinition($form_arg);
}
}