You are here

public static function FieldgroupUi::getDeleteRoute in Field Group 8

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

Get the field group delete route for a given group.

Parameters

\stdClass $group:

Return value

\Drupal\Core\Url A URL object.

1 call to FieldgroupUi::getDeleteRoute()
field_group_field_ui_display_form_alter in includes/field_ui.inc
Function to alter the display overview screens.

File

src/FieldgroupUi.php, line 60

Class

FieldgroupUi
Static methods for fieldgroup UI.

Namespace

Drupal\field_group

Code

public static function getDeleteRoute($group) {
  $entity_type_id = $group->entity_type;
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id);
  if ($entity_type
    ->get('field_ui_base_route')) {
    $mode_route_name = '';
    $route_parameters = FieldUI::getRouteBundleParameter($entity_type, $group->bundle);
    $route_parameters['field_group_name'] = $group->group_name;

    // Get correct route name based on context and mode.
    if ($group->context == 'form') {
      $context_route_name = 'form_display';
      if ($group->mode != 'default') {
        $mode_route_name = '.form_mode';
        $route_parameters['form_mode_name'] = $group->mode;
      }
    }
    else {
      $context_route_name = 'display';
      if ($group->mode != 'default') {
        $mode_route_name = '.view_mode';
        $route_parameters['view_mode_name'] = $group->mode;
      }
    }
    return new Url('field_ui.field_group_delete_' . $entity_type_id . '.' . $context_route_name . $mode_route_name, $route_parameters);
  }
  throw new \InvalidArgumentException('The given group is not a valid.');
}