rc-1.0.x-dev/modules/rc_group/rc_group.install

modules/rc_group/rc_group.install
<?php

use Drupal\field\Entity\FieldConfig;

/**
 * Implements hook_uninstall().
 *
 * @throws \Drupal\Core\Entity\EntityStorageException
 */
function rc_group_uninstall($is_syncing) {

  // Delete Room ID field from group type entities.
  $list = [];
  $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo('group');
  foreach ($bundles as $key => $bundle) {

    // Load the field.
    $field = FieldConfig::loadByName('group', $key, 'field_rc_room_id');

    if ($field) {
      // Deleting the Room ID field.
      FieldConfig::loadByName('group', $key, 'field_rc_room_id')
        ->delete();

      \Drupal::messenger()
        ->addStatus('The Room ID field has been removed from ' . $key . ' group type.');
    }
  }

  // Delete RC Groups view.
  $view = \Drupal::service('config.factory')
    ->getEditable('views.view.rc_groups');
    if ($view) {
      $view->delete();
    }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc