You are here

metatag_views.install in Metatag 8

Same filename and directory in other branches
  1. 7 metatag_views/metatag_views.install

Various install/uninstall hooks for the Metatag Views module.

File

metatag_views/metatag_views.install
View source
<?php

/**
 * @file
 * Various install/uninstall hooks for the Metatag Views module.
 */

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

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

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

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

/**
 * Implementations of hook_update_N().
 */

/**
 * Notify admins that the custom admin pages were (temporarily) disabled.
 */
function metatag_views_update_8100() {
  return (string) t("The custom admin pages for managing Views meta tags at /admin/config/search/metatag/views have been disabled for now, hopefully they'll be back in a future release. Until then, the meta tags can be managed directly on each individual view via the \"Meta tags\" section.");
}

/**
 * Empty update script to trigger a cache clear.
 */
function metatag_views_update_8101() {
  return (string) t("Empty update script to clear the site's caches so the new token replacement functionality will work.");
}

Functions

Namesort descending Description
metatag_views_install Implements hook_install().
metatag_views_uninstall Implements hook_uninstall().
metatag_views_update_8100 Notify admins that the custom admin pages were (temporarily) disabled.
metatag_views_update_8101 Empty update script to trigger a cache clear.