You are here

function conditional_fields_features_rebuild in Conditional Fields 7.3

Same name and namespace in other branches
  1. 6.2 includes/conditional_fields.features.inc \conditional_fields_features_rebuild()

Implements hook_features_rebuild().

1 call to conditional_fields_features_rebuild()
conditional_fields_features_revert in includes/conditional_fields.features.inc
Implements hook_features_revert().

File

includes/conditional_fields.features.inc, line 90
Features integration hooks.

Code

function conditional_fields_features_rebuild($module) {
  $defaults = features_get_default('conditional_fields', $module);
  if (!empty($defaults)) {
    $dependencies = conditional_fields_load_dependencies();
    $instances = field_info_instances();
    foreach ($defaults as $item) {
      foreach ($item as $field) {
        if (isset($dependencies[$field['entity']][$field['bundle']])) {
          foreach ($dependencies[$field['entity']][$field['bundle']] as $dependancy_type => $field_dep_settings) {
            if ($dependancy_type == 'dependees' && !empty($field_dep_settings)) {
              foreach ($field_dep_settings as $dep_setting) {
                foreach ($dep_setting as $id => $dep_settings) {
                  $deps_to_remove[$id] = $id;
                }
              }
            }
          }
          if (!empty($deps_to_remove)) {
            conditional_fields_dependency_delete($deps_to_remove);
          }
        }
        $entity_instances = $instances[$field['entity']][$field['bundle']];
        $dependee_id = $entity_instances[$field['dependee']]['id'];
        $dependent_id = $entity_instances[$field['dependent']]['id'];
        conditional_fields_dependency_insert($dependee_id, $dependent_id, $field['options']);
      }
    }
  }
}