You are here

protected function EntityFormModeBase::getEntityTypeFromRouteMatch in Form mode manager 8

Retrieves entity from route match.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

array The entity object as determined from the passed-in route match.

4 calls to EntityFormModeBase::getEntityTypeFromRouteMatch()
EntityFormModeBase::checkAccess in src/Controller/EntityFormModeBase.php
Checks access for the Form Mode Manager routes.
EntityFormModeBase::entityAdd in src/Controller/EntityFormModeBase.php
Provides the entity add submission form.
EntityFormModeBase::getEntityBundle in src/Controller/EntityFormModeBase.php
Get EntityStorage of entity.
UserFormModeController::getEntityTypeFromRouteMatch in src/Controller/UserFormModeController.php
Retrieves entity from route match.
1 method overrides EntityFormModeBase::getEntityTypeFromRouteMatch()
UserFormModeController::getEntityTypeFromRouteMatch in src/Controller/UserFormModeController.php
Retrieves entity from route match.

File

src/Controller/EntityFormModeBase.php, line 443

Class

EntityFormModeBase
Controller for entity form mode support.

Namespace

Drupal\form_mode_manager\Controller

Code

protected function getEntityTypeFromRouteMatch(RouteMatchInterface $route_match) {
  $route = $route_match
    ->getRouteObject();
  $entity_type_id = $route
    ->getOption('_form_mode_manager_entity_type_id');
  $bundle_entity_type_id = $route
    ->getOption('_form_mode_manager_bundle_entity_type_id');
  $form_mode = $this->formModeManager
    ->getFormModeMachineName($route
    ->getDefault('_entity_form'));
  $bundle = $route_match
    ->getRawParameter($bundle_entity_type_id);
  $form_mode_definition = $this->formModeManager
    ->getActiveDisplaysByBundle($entity_type_id, $bundle);
  $entity_type_key = $this->entityTypeManager
    ->getDefinition($entity_type_id)
    ->getKey('bundle');
  return [
    'bundle' => $bundle,
    'bundle_entity_type' => $bundle_entity_type_id,
    'entity_key' => $entity_type_key,
    'entity_type_id' => $entity_type_id,
    'form_mode' => isset($form_mode_definition[$entity_type_id][$form_mode]) ? $form_mode_definition[$entity_type_id][$form_mode] : NULL,
  ];
}