class FormRouteEnhancer

Same name in other branches
  1. 9 core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php \Drupal\Core\Routing\Enhancer\FormRouteEnhancer
  2. 8.9.x core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php \Drupal\Core\Routing\Enhancer\FormRouteEnhancer
  3. 10 core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php \Drupal\Core\Routing\Enhancer\FormRouteEnhancer

Enhancer to add a wrapping controller for _form routes.

Hierarchy

Expanded class hierarchy of FormRouteEnhancer

File

core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php, line 13

Namespace

Drupal\Core\Routing\Enhancer
View source
class FormRouteEnhancer implements EnhancerInterface {
    
    /**
     * Returns whether the enhancer runs on the current route.
     *
     * @param \Symfony\Component\Routing\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

Title Sort descending Modifiers Object type Summary Overriden Title
FormRouteEnhancer::applies protected function Returns whether the enhancer runs on the current route.
FormRouteEnhancer::enhance public function Updates the defaults for a route definition based on the request. Overrides EnhancerInterface::enhance

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.