class FormRouteEnhancer in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php \Drupal\Core\Routing\Enhancer\FormRouteEnhancer
Enhancer to add a wrapping controller for _form routes.
Hierarchy
- class \Drupal\Core\Routing\Enhancer\FormRouteEnhancer implements EnhancerInterface
Expanded class hierarchy of FormRouteEnhancer
1 string reference to 'FormRouteEnhancer'
- core.services.yml in core/core.services.yml 
- core/core.services.yml
1 service uses FormRouteEnhancer
File
- core/lib/ Drupal/ Core/ Routing/ Enhancer/ FormRouteEnhancer.php, line 13 
Namespace
Drupal\Core\Routing\EnhancerView source
class FormRouteEnhancer implements EnhancerInterface {
  /**
   * Returns whether the enhancer runs on the current route.
   *
   * @param \Drupal\Core\Routing\Enhancer\Route $route
   *   The current route.
   *
   * @return bool
   */
  protected function applies(Route $route) {
    return $route
      ->hasDefault('_form') && !$route
      ->hasDefault('_controller');
  }
  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
    if (!$this
      ->applies($route)) {
      return $defaults;
    }
    $defaults['_controller'] = 'controller.form:getContentResult';
    return $defaults;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| FormRouteEnhancer:: | protected | function | Returns whether the enhancer runs on the current route. | |
| FormRouteEnhancer:: | public | function | Updates the defaults for a route definition based on the request. Overrides EnhancerInterface:: | 
