You are here

function calendar_systems_date_properties_schema_alter in Calendar Systems 8

Same name and namespace in other branches
  1. 7 calendar_systems_date_properties/calendar_systems_date_properties.module \calendar_systems_date_properties_schema_alter()
  2. 7.2 calendar_systems_date_properties/calendar_systems_date_properties.module \calendar_systems_date_properties_schema_alter()

Implements hook_schema_alter().

Parameters

$schema: The system-wide schema

File

calendar_systems_date_properties/calendar_systems_date_properties.module, line 95
Contains hook implementations and helpers.

Code

function calendar_systems_date_properties_schema_alter(&$schema) {
  $entity_types = _calendar_systems_date_properties_entity_types();
  foreach ($entity_types as $entity_type => $entity_type_info) {
    if (isset($entity_type_info['integrated']) && $entity_type_info['integrated']) {

      //dsm($entity_type);

      //dsm($entity_type_info);
      foreach ($entity_type_info['properties'] as $property_name => $property) {
        if (isset($entity_type_info['selected_properties'][$property_name])) {
          $calendar_systems = _calendar_systems_date_properties_get_active_calendar_systems();
          foreach ($calendar_systems as $calendar_system) {
            foreach ($calendar_system['parts'] as $calendar_system_part_name => $calendar_system_part) {
              $new_property_label = t($entity_type_info['properties'][$property_name]['label']) . ' ' . t($calendar_system['name']) . ' ' . t($calendar_system_part['label']);
              $new_property_name = $property_name . '_' . $calendar_system['name'] . '_' . $calendar_system_part_name;
              $schema[$entity_type_info['base table']]['fields'][$new_property_name] = array(
                'description' => $new_property_label,
                'type' => 'int',
                'not null' => FALSE,
                'default' => NULL,
              );
            }
          }
        }
      }
    }
  }
}