You are here

dynamic_banner.install in Dynamic Banner 8

The install file of dynamic_banner

File

dynamic_banner.install
View source
<?php

// $Id$

/**
 * @file
 * The install file of dynamic_banner
 */

/**
 * Implements hook_schema().
 *
 * Will create the database needed to store the banner connections
 */
function dynamic_banner_schema() {
  $schema['dynamic_banner'] = array(
    'description' => 'The table for the path to banner relationship',
    'fields' => array(
      'dbid' => array(
        'description' => 'The primary key always unique',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'path' => array(
        'description' => 'The path of the page where this banner will live',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'imgurl' => array(
        'description' => 'The path of the image for the banner',
        'type' => 'text',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'imgfid' => array(
        'description' => 'If the image is managed these are the fids of the image for the banner',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'text' => array(
        'description' => 'The text to display on this relationship',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'link' => array(
        'description' => 'The link to make the banner point to',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'mode' => array(
        'description' => 'The Mode for this page, will be things like time_base, rotating, fade, normal (visual mode)',
        'type' => 'varchar',
        'length' => '30',
        'not null' => FALSE,
      ),
      'start_time' => array(
        'description' => 'The Start time for this banner, when it activates',
        'type' => 'varchar',
        'length' => '60',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'end_time' => array(
        'description' => 'The End time for this banner, when it expires',
        'type' => 'varchar',
        'length' => '60',
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'primary key' => array(
      'dbid',
    ),
  );
  return $schema;
}

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

  // default settings install
  $config = \Drupal::service('config.factory')
    ->getEditable('dynamic_banner.settings');

  // Set and save new message value.
  $config
    ->set('dynamic_banner_display_setting', 'urltext')
    ->set('dynamic_banner_display_errors', FALSE)
    ->set('dynamic_banner_block_name', 'Dynamic Banner Block')
    ->set('dynamic_banner_mode', 'normal')
    ->set('dynamic_banner_file_save_path', 'public://banners/')
    ->save();
  \Drupal::messenger()
    ->addWarning(t('Dynamic Banner Module installed successfully.'));
}

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

  // default settings remove
  Drupal::configFactory()
    ->getEditable('dynamic_banner.settings')
    ->delete();
  \Drupal::messenger()
    ->addWarning(t('Dynamic Banner Module uninstalled successfully.'));
}

Functions