You are here

function vimeo_video_uploader_data_remove in Vimeo Video Uploader 8

Same name and namespace in other branches
  1. 8.4 vimeo_video_uploader.install \vimeo_video_uploader_data_remove()
  2. 7.2 vimeo_video_uploader.install \vimeo_video_uploader_data_remove()
  3. 7 vimeo_video_uploader.install \vimeo_video_uploader_data_remove()

Delete fields and fields data.

2 calls to vimeo_video_uploader_data_remove()
vimeo_video_uploader_disable in ./vimeo_video_uploader.install
Implements hook_disable().
vimeo_video_uploader_uninstall in ./vimeo_video_uploader.install
Implements hook_uninstall().

File

./vimeo_video_uploader.install, line 24

Code

function vimeo_video_uploader_data_remove() {
  $config = \Drupal::config('vimeo_video_uploader.settings');
  $content_type = $config
    ->get('values.content_type_select');
  if (!empty($content_type)) {
    $entityManager = \Drupal::service('entity.manager');
    $fields = $entityManager
      ->getFieldDefinitions('node', $content_type);
    if (isset($fields['field_vimeo_file_browse']) && ($field = $fields['field_vimeo_file_browse'])) {
      $field
        ->delete();
    }
    if (isset($fields['field_embeddedvideo']) && ($field1 = $fields['field_embeddedvideo'])) {
      $field1
        ->delete();
    }
  }
  $delete = [
    'vimeo_video_uploader.client_id',
    'vimeo_video_uploader.client_secret',
    'vimeo_video_uploader.access_token',
    'vimeo_video_uploader.content_type_select',
  ];
  \Drupal::state()
    ->deleteMultiple($delete);
}