FormRouteEnhancer.php in Drupal 9
File
core/lib/Drupal/Core/Routing/Enhancer/FormRouteEnhancer.php
View source
<?php
namespace Drupal\Core\Routing\Enhancer;
use Drupal\Core\Routing\EnhancerInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
class FormRouteEnhancer implements EnhancerInterface {
protected function applies(Route $route) {
return $route
->hasDefault('_form') && !$route
->hasDefault('_controller');
}
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;
}
}