You are here

vimeo_video_uploader.install in Vimeo Video Uploader 8

File

vimeo_video_uploader.install
View source
<?php

/**
 * @file
 */

/**
 * Implements hook_disable().
 */
function vimeo_video_uploader_disable() {
  vimeo_video_uploader_data_remove();
}

/**
 * Implements hook_uninstall().
 */
function vimeo_video_uploader_uninstall() {
  vimeo_video_uploader_data_remove();
}

/**
 * Delete fields and fields data.
 */
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);
}

/**
 * Implementation of hook_requirements().
 */
function vimeo_video_uploader_requirements($phase) {
  $requirements = array();
  if ($phase == 'install') {
    if (!is_dir('vendor/vimeo')) {
      $requirements['vimeo-api'] = array(
        'severity' => REQUIREMENT_ERROR,
        'description' => t('The required Vimeo library is not found.
                            See modules README.txt for instructions.', array(
          '@link' => 'https://www.drupal.org/node/2726121',
        )),
      );
    }
  }
  return $requirements;
}

Functions

Namesort descending Description
vimeo_video_uploader_data_remove Delete fields and fields data.
vimeo_video_uploader_disable Implements hook_disable().
vimeo_video_uploader_requirements Implementation of hook_requirements().
vimeo_video_uploader_uninstall Implements hook_uninstall().