You are here

tft.install in Taxonomy File Tree 8

Same filename and directory in other branches
  1. 7.2 tft.install
  2. 7 tft.install
  3. 3.x tft.install

Install, update and uninstall functions for the TFT module.

File

tft.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the TFT module.
 */
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Config\FileStorage;

/**
 * Creates the opigno_moxtra_recording_link field in the tft_file.
 */
function tft_update_8001() {
  $config_path = drupal_get_path('module', 'tft') . '/config/optional';
  $storage = new FileStorage($config_path);
  $data = $storage
    ->read('field.storage.media.opigno_moxtra_recording_link');
  if (!FieldStorageConfig::loadByName($data['entity_type'], $data['field_name'])) {
    FieldStorageConfig::create($data)
      ->save();
  }
  $data = $storage
    ->read('field.field.media.tft_file.opigno_moxtra_recording_link');
  if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
    FieldConfig::create($data)
      ->save();
  }
}

/**
 * Creates the tft_members field in the tft_file.
 */
function tft_update_8002() {
  $config_path = drupal_get_path('module', 'tft') . '/config/optional';
  $storage = new FileStorage($config_path);
  $data = $storage
    ->read('field.storage.media.tft_members');
  if (!FieldStorageConfig::loadByName($data['entity_type'], $data['field_name'])) {
    FieldStorageConfig::create($data)
      ->save();
  }
  $data = $storage
    ->read('field.field.media.tft_file.tft_members');
  if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
    FieldConfig::create($data)
      ->save();
  }
}

/**
 * Update tft_file field settings.
 */
function tft_update_8003() {
  $config_path = drupal_get_path('module', 'tft') . '/config/optional';
  $storage = new FileStorage($config_path);
  $config_storage = \Drupal::service('config.storage');
  $data = $storage
    ->read('field.storage.media.tft_file');
  $config_storage
    ->write('field.storage.media.tft_file', $data);
}

/**
 * Update tft_file field settings. Hide field label.
 */
function tft_update_8004() {
  $config_path = drupal_get_path('module', 'tft') . '/config/optional';
  $storage = new FileStorage($config_path);
  $config_storage = \Drupal::service('config.storage');
  $data = $storage
    ->read('core.entity_view_display.media.tft_file.default');
  $config_storage
    ->write('core.entity_view_display.media.tft_file.default', $data);
}

Functions

Namesort descending Description
tft_update_8001 Creates the opigno_moxtra_recording_link field in the tft_file.
tft_update_8002 Creates the tft_members field in the tft_file.
tft_update_8003 Update tft_file field settings.
tft_update_8004 Update tft_file field settings. Hide field label.