You are here

bat_booking_example.install in Booking and Availability Management Tools for Drupal 8

Same filename and directory in other branches
  1. 7 modules/bat_booking/bat_booking_example/bat_booking_example.install

File

modules/bat_booking/bat_booking_example/bat_booking_example.install
View source
<?php

/**
 * Implements hook_install().
 */
function bat_booking_example_install() {
  bat_booking_example_create_availability_event_type();
  bat_booking_example_create_standard_event_states();
}

/**
 * Implements hook_uninstall().
 */
function bat_booking_example_uninstall() {
  bat_booking_example_delete_availability_event_type();
}

/**
 * Create the "Availability Example" event type.
 */
function bat_booking_example_create_availability_event_type() {
  $event_type = bat_event_type_create([
    'name' => 'Availability Example',
    'type' => 'availability_example',
    'fixed_event_states' => 1,
    'event_granularity' => 'bat_daily',
    'target_entity_type' => 'bat_unit',
  ]);
  bat_event_type_save($event_type);
}

/**
 * Creates the default event states.
 */
function bat_booking_example_create_standard_event_states() {
  $event_state = bat_event_create_state([
    'name' => 'Available',
    'color' => '#8BA175',
    'calendar_label' => 'AV',
    'event_type' => 'availability_example',
  ]);
  bat_event_save_state($event_state);
  $event_state = bat_event_create_state([
    'name' => 'Not Available',
    'color' => '#CC2727',
    'calendar_label' => 'N/A',
    'event_type' => 'availability_example',
  ]);
  bat_event_save_state($event_state);
  $event_state = bat_event_create_state([
    'name' => 'Booked',
    'color' => '#1A1A73',
    'calendar_label' => 'Booked',
    'blocking' => 1,
    'event_type' => 'availability_example',
  ]);
  bat_event_save_state($event_state);
}

/**
 * Delete the "Availability Example" event type.
 */
function bat_booking_example_delete_availability_event_type() {
  if ($event_type = bat_event_type_load('availability_example')) {
    bat_event_type_delete($event_type);
  }
}

Functions

Namesort descending Description
bat_booking_example_create_availability_event_type Create the "Availability Example" event type.
bat_booking_example_create_standard_event_states Creates the default event states.
bat_booking_example_delete_availability_event_type Delete the "Availability Example" event type.
bat_booking_example_install Implements hook_install().
bat_booking_example_uninstall Implements hook_uninstall().