You are here

file_management_view.install in File Management 8

Install, update and uninstall functions for the file_management_view module.

File

modules/file_management_view/file_management_view.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the file_management_view module.
 */

/**
 * Implements hook_install().
 */
function file_management_view_install() {

  // Disable the existing files view since we add our own view.
  $files_view = \Drupal::entityTypeManager()
    ->getStorage('view')
    ->load('files');
  if (!empty($files_view)) {
    $files_view
      ->setStatus(FALSE);
    $files_view
      ->save();
  }
}

/**
 * Implements hook_uninstall().
 */
function file_management_view_uninstall() {

  // Remove our own view.
  $file_management_view = \Drupal::entityTypeManager()
    ->getStorage('view')
    ->load('file_management');
  $file_management_view
    ->delete();

  // Re-enable the existing files view.
  $files_view = \Drupal::entityTypeManager()
    ->getStorage('view')
    ->load('files');
  if (!empty($files_view)) {
    $files_view
      ->setStatus(TRUE);
    $files_view
      ->save();
  }
}