You are here

views_attach_library.install in Views Attach Library 8

Same filename and directory in other branches
  1. 8.x views_attach_library.install
  2. 2.0.x views_attach_library.install

Various install/uninstall hooks for the attach library views module.

File

views_attach_library.install
View source
<?php

/**
 * @file
 * Various install/uninstall hooks for the attach library views module.
 */

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

  // Enable library_in_views_display_extender plugin.
  $config = \Drupal::service('config.factory')
    ->getEditable('views.settings');
  $display_extenders = $config
    ->get('display_extenders') ?: [];
  $display_extenders[] = 'library_in_views_display_extender';
  $config
    ->set('display_extenders', $display_extenders);
  $config
    ->save();
}

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

  // Disable library_in_views_display_extender plugin.
  $config = \Drupal::service('config.factory')
    ->getEditable('views.settings');
  $display_extenders = $config
    ->get('display_extenders') ?: [];
  $key = array_search('library_in_views_display_extender', $display_extenders);
  if ($key !== FALSE) {
    unset($display_extenders[$key]);
    $config
      ->set('display_extenders', $display_extenders);
    $config
      ->save();
  }
}