You are here

protected function FormModeManagerConverter::getEntityForm in Form mode manager 8

Get the entity loaded into current route.

If we are in classic case _entity_form are always here, but in custom "list_page" route provide by FormModeManager, We need to retrive the entity_type in "_route_object".

Parameters

array $defaults: The route defaults array.

array $definition: The parameter definition provided in the route options.

Return value

string|false Extract the entity_type_id of current entity.

File

src/ParamConverter/FormModeManagerConverter.php, line 73

Class

FormModeManagerConverter
Converter for form_mode_manager routes.

Namespace

Drupal\form_mode_manager\ParamConverter

Code

protected function getEntityForm(array $defaults, array $definition) {
  $entity_form = $defaults['_entity_form'];
  $form_mode_id = $defaults['_route_object']
    ->getOption('_form_mode_manager_entity_type_id') . '.' . $defaults['form_mode_name'];
  if ($entity_form === $form_mode_id) {
    return explode('.', $defaults['_entity_form'])[0];
  }
  return FALSE;
}