public function MediaEntityFormModes::getEntityFromRouteMatch in Form mode manager 8.2
Return value
\Drupal\Core\Entity\EntityInterface A new entity object build with given route_match.
Overrides ComplexEntityFormModes::getEntityFromRouteMatch
File
- src/
MediaEntityFormModes.php, line 18
Class
- MediaEntityFormModes
- Route controller factory specific for Media (core) entities.
Namespace
Drupal\form_mode_managerCode
public function getEntityFromRouteMatch(RouteMatchInterface $route_match) {
$entity_type_id = $route_match
->getRouteObject()
->getOption('_form_mode_manager_entity_type_id');
$bundle_entity_type_id = $route_match
->getRouteObject()
->getOption('_form_mode_manager_bundle_entity_type_id');
$entity = $route_match
->getParameter($entity_type_id);
if (empty($entity)) {
$entity = $this->entityTypeManager
->getStorage($entity_type_id)
->create([
'bundle' => $route_match
->getRawParameter($bundle_entity_type_id),
]);
}
return $entity;
}