public function FieldUiRouteEnhancer::enhance in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php \Drupal\field_ui\Routing\FieldUiRouteEnhancer::enhance()
Updates the defaults for a route definition based on the request.
Parameters
array $defaults: The defaults, maps to '_defaults' in the route definition YAML.
\Symfony\Component\HttpFoundation\Request $request: The Request instance.
Return value
array The modified defaults. Each enhancer MUST return the $defaults but may add or remove values.
Overrides EnhancerInterface::enhance
File
- core/
modules/ field_ui/ src/ Routing/ FieldUiRouteEnhancer.php, line 36
Class
- FieldUiRouteEnhancer
- Enhances Field UI routes by adding proper information about the bundle name.
Namespace
Drupal\field_ui\RoutingCode
public function enhance(array $defaults, Request $request) {
if (!$this
->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
return $defaults;
}
if (($bundle = $this->entityTypeManager
->getDefinition($defaults['entity_type_id'])
->getBundleEntityType()) && isset($defaults[$bundle])) {
// Field UI forms only need the actual name of the bundle they're dealing
// with, not an upcasted entity object, so provide a simple way for them
// to get it.
$defaults['bundle'] = $defaults['_raw_variables']
->get($bundle);
}
return $defaults;
}