You are here

public static function FieldgroupUi::getFieldUiRoute in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/FieldgroupUi.php \Drupal\field_group\FieldgroupUi::getFieldUiRoute()

Get the field ui route that should be used for given arguments.

Parameters

stdClass $group: The group to get the field ui route for.

Return value

\Drupal\Core\Url A URL object.

2 calls to FieldgroupUi::getFieldUiRoute()
FieldGroupAddForm::submitForm in src/Form/FieldGroupAddForm.php
Form submission handler.
FieldGroupDeleteForm::getCancelUrl in src/Form/FieldGroupDeleteForm.php
Returns the route to go to if the user cancels the action.

File

src/FieldgroupUi.php, line 20

Class

FieldgroupUi
Static methods for fieldgroup UI.

Namespace

Drupal\field_group

Code

public static function getFieldUiRoute($group) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($group->entity_type);
  if ($entity_type
    ->get('field_ui_base_route')) {
    $context_route_name = "";
    $mode_route_name = "default";
    $route_parameters = FieldUI::getRouteBundleParameter($entity_type, $group->bundle);

    // Get correct route name based on context and mode.
    if ($group->context == 'form') {
      $context_route_name = 'entity_form_display';
      if ($group->mode != 'default') {
        $mode_route_name = 'form_mode';
        $route_parameters['form_mode_name'] = $group->mode;
      }
    }
    else {
      $context_route_name = 'entity_view_display';
      if ($group->mode != 'default') {
        $mode_route_name = 'view_mode';
        $route_parameters['view_mode_name'] = $group->mode;
      }
    }
    return new Url("entity.{$context_route_name}.{$group->entity_type}.{$mode_route_name}", $route_parameters);
  }
}