MediaEntityFormModes.php in Form mode manager 8.2
File
src/MediaEntityFormModes.php
View source
<?php
namespace Drupal\form_mode_manager;
use Drupal\Core\Routing\RouteMatchInterface;
class MediaEntityFormModes extends ComplexEntityFormModes {
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;
}
}