You are here

function field_group_delete_field_group in Field Group 8.3

Delete a field group.

Parameters

$group: A group definition.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to field_group_delete_field_group()
FieldGroupDeleteForm::submitForm in src/Form/FieldGroupDeleteForm.php
Form submission handler.

File

./field_group.module, line 927
Allows administrators to attach field groups.

Code

function field_group_delete_field_group($group) {
  if ($group->context == 'form') {
    $display = EntityFormDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode);
  }
  elseif ($group->context == 'view') {
    $display = EntityViewDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode);
  }

  /**
   * @var $display \Drupal\Core\Entity\Display\EntityDisplayInterface
   */
  if (isset($display)) {
    $display
      ->unsetThirdPartySetting('field_group', $group->group_name);
    $display
      ->save();
  }
  Drupal::moduleHandler()
    ->invokeAll('field_group_delete_field_group', [
    $group,
  ]);
}