You are here

function registration_checkin_install in Entity Registration 8.2

Same name and namespace in other branches
  1. 7.2 modules/registration_checkin/registration_checkin.install \registration_checkin_install()

Implements hook_install().

File

modules/registration_checkin/registration_checkin.install, line 23
Install/update hooks for registration checkin.

Code

function registration_checkin_install() {

  // Add the "attended" column to registration_state table.
  $col = array(
    'description' => 'A boolean indicating whether or not the registrant attended.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'size' => 'tiny',
  );
  db_add_field('registration_state', 'attended', $col);

  // Create the "attended" registration state entity.
  $attended_state = registration_get_states('attended');
  if (!$attended_state) {
    $attended_state = \Drupal::entityManager()
      ->getStorage('registration_state')
      ->create(array(
      'name' => 'attended',
      'label' => t('Attended'),
      'description' => t('Registrant has attended.'),
    ));
  }
  $attended_state->active = TRUE;
  $attended_state->attended = TRUE;
  $attended_state->show_on_form = TRUE;
  $attended_state
    ->save();
  drupal_set_message('Created the "Attended" registration state.');
}