You are here

public function SimpleEntityFormModes::getEntityTypeFromRouteMatch in Form mode manager 8.2

Return value

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

Overrides AbstractEntityFormModesFactory::getEntityTypeFromRouteMatch

2 calls to SimpleEntityFormModes::getEntityTypeFromRouteMatch()
SimpleEntityFormModes::checkAccess in src/SimpleEntityFormModes.php
Checks access for the Form Mode Manager routes.
SimpleEntityFormModes::getEntity in src/SimpleEntityFormModes.php

File

src/SimpleEntityFormModes.php, line 54

Class

SimpleEntityFormModes
Route controller factory specific for each entities not using bundles.

Namespace

Drupal\form_mode_manager

Code

public function getEntityTypeFromRouteMatch(RouteMatchInterface $route_match) {
  $route = $route_match
    ->getRouteObject();
  $entity_type_id = $route
    ->getOption('_form_mode_manager_entity_type_id');
  $form_mode = $this->formModeManager
    ->getFormModeMachineName($route
    ->getDefault('_entity_form'));
  $form_mode_definition = $this->formModeManager
    ->getActiveDisplaysByBundle($entity_type_id, $entity_type_id);
  return [
    '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,
  ];
}