You are here

empty_page.install in Empty Page 8

Same filename and directory in other branches
  1. 7 empty_page.install

Installation file.

File

empty_page.install
View source
<?php

/**
 * @file
 * Installation file.
 */

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

  // When menu items are being retrieved, Empty Page's routes
  // to come last so that path overrides work.
  module_set_weight('empty_page', 1000);
}

/**
 * Implements hook_update_N().
 */
function empty_page_update_8101(&$sandbox) {
  if (\Drupal::database()
    ->schema()
    ->tableExists('empty_page')) {
    $id = 0;
    $records = \Drupal::database()
      ->select('empty_page', 't')
      ->fields('t', [])
      ->orderBy('cid', 'ASC')
      ->execute()
      ->fetchAll();
    $config = \Drupal::configFactory()
      ->getEditable('empty_page.settings');
    foreach ($records as $record) {
      $config = $config
        ->set('callback_' . $record->cid, (array) $record);
      $id = $record->cid;
    }
    $config
      ->set('new_id', $id + 1)
      ->save();

    // Delete the table.
    \Drupal::database()
      ->schema()
      ->dropTable('empty_page');
  }
}

Functions

Namesort descending Description
empty_page_install Implements hook_install().
empty_page_update_8101 Implements hook_update_N().