public function TaxonomyEntityFormModes::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/
TaxonomyEntityFormModes.php, line 18
Class
- TaxonomyEntityFormModes
- Route controller factory specific for Taxonomy Term 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([
'vid' => $route_match
->getRawParameter($bundle_entity_type_id),
]);
}
return $entity;
}