Enhances a form route with the appropriate controller.
Expanded class hierarchy of FormEnhancer
class FormEnhancer implements RouteEnhancerInterface {
/**
* Content negotiation library.
*
* @var \Drupal\CoreContentNegotiation
*/
protected $negotiation;
/**
* Constructs a new \Drupal\Core\Routing\Enhancer\FormEnhancer object.
*
* @param \Drupal\Core\ContentNegotiation $negotiation
* The Content Negotiation service.
*/
public function __construct(ContentNegotiation $negotiation) {
$this->negotiation = $negotiation;
}
/**
* {@inhertdoc}
*/
public function enhance(array $defaults, Request $request) {
if (empty($defaults['_controller']) && !empty($defaults['_form']) && $this->negotiation
->getContentType($request) === 'html') {
$defaults['_controller'] = '\\Drupal\\Core\\Controller\\HtmlFormController::content';
}
return $defaults;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormEnhancer:: |
protected | property | Content negotiation library. | |
FormEnhancer:: |
public | function |
{@inhertdoc} Overrides RouteEnhancerInterface:: |
|
FormEnhancer:: |
public | function | Constructs a new \Drupal\Core\Routing\Enhancer\FormEnhancer object. |