class FlexiformRouteEnhancer in Flexiform 8
Enhances Flexiform routes.
To get the form display object from request attributes.
Hierarchy
- class \Drupal\flexiform\Routing\FlexiformRouteEnhancer implements EnhancerInterface
Expanded class hierarchy of FlexiformRouteEnhancer
1 string reference to 'FlexiformRouteEnhancer'
1 service uses FlexiformRouteEnhancer
File
- src/
Routing/ FlexiformRouteEnhancer.php, line 15
Namespace
Drupal\flexiform\RoutingView source
class FlexiformRouteEnhancer implements EnhancerInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a FlexiformRouteEnhancer object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function enhance(array $defaults, Request $request) {
/* @var \Symfony\Component\Routing\Route $route */
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
if (!$route
->hasOption('_flexiform_form_entity')) {
return $defaults;
}
$defaults['form_display'] = $this->entityTypeManager
->getStorage('entity_form_display')
->load($defaults['entity_type_id'] . '.' . $defaults['bundle'] . '.' . $defaults['form_mode_name']);
return $defaults;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlexiformRouteEnhancer:: |
protected | property | The entity type manager. | |
FlexiformRouteEnhancer:: |
public | function | ||
FlexiformRouteEnhancer:: |
public | function | Constructs a FlexiformRouteEnhancer object. |