class FieldUiRouteEnhancer in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php \Drupal\field_ui\Routing\FieldUiRouteEnhancer
Enhances Field UI routes by adding proper information about the bundle name.
Hierarchy
- class \Drupal\field_ui\Routing\FieldUiRouteEnhancer implements RouteEnhancerInterface
Expanded class hierarchy of FieldUiRouteEnhancer
1 string reference to 'FieldUiRouteEnhancer'
- field_ui.services.yml in core/
modules/ field_ui/ field_ui.services.yml - core/modules/field_ui/field_ui.services.yml
1 service uses FieldUiRouteEnhancer
- field_ui.route_enhancer in core/
modules/ field_ui/ field_ui.services.yml - Drupal\field_ui\Routing\FieldUiRouteEnhancer
File
- core/
modules/ field_ui/ src/ Routing/ FieldUiRouteEnhancer.php, line 18 - Contains \Drupal\field_ui\Routing\FieldUiRouteEnhancer.
Namespace
Drupal\field_ui\RoutingView source
class FieldUiRouteEnhancer implements RouteEnhancerInterface {
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Constructs a FieldUiRouteEnhancer object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public function enhance(array $defaults, Request $request) {
if (($bundle = $this->entityManager
->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;
}
/**
* {@inheritdoc}
*/
public function applies(Route $route) {
return $route
->hasOption('_field_ui');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldUiRouteEnhancer:: |
protected | property | The entity manager. | |
FieldUiRouteEnhancer:: |
public | function |
Declares if the route enhancer applies to the given route. Overrides RouteEnhancerInterface:: |
|
FieldUiRouteEnhancer:: |
public | function |
Update the defaults based on its own data and the request. Overrides RouteEnhancerInterface:: |
|
FieldUiRouteEnhancer:: |
public | function | Constructs a FieldUiRouteEnhancer object. |