You are here

mobile_device_detection.install in Mobile Device Detection 8.3

Same filename and directory in other branches
  1. 8.2 mobile_device_detection.install

Default install and uninstall functions which set up default data.

File

mobile_device_detection.install
View source
<?php

/**
 * @file
 * Default install and uninstall functions which set up default data.
 */

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

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

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

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