You are here

function bat_event_update_8003 in Booking and Availability Management Tools for Drupal 8

Set Event fields as required.

File

modules/bat_event/bat_event.install, line 78
Sets up the base table for our entity and a table to store information about the entity types.

Code

function bat_event_update_8003() {
  foreach (bat_event_get_types() as $event_type) {
    $field_names = [
      'event_dates',
      'event_' . $event_type
        ->getTargetEntityType() . '_reference',
    ];
    if ($event_type
      ->getFixedEventStates()) {
      $field_names[] = 'event_state_reference';
    }
    foreach ($field_names as $field_name) {
      $field = FieldConfig::loadByName('bat_event', $event_type
        ->id(), $field_name);
      $field
        ->setRequired(TRUE);
      $field
        ->save();
    }
  }
}