You are here

function config_pages_features_rebuild in Config Pages 7

Implements hook_features_rebuild().

1 call to config_pages_features_rebuild()
config_pages_features_revert in ./config_pages.features.inc
Implements hook_features_revert().

File

./config_pages.features.inc, line 187
Integrates with features.

Code

function config_pages_features_rebuild($module) {

  // Load all defaults for this config.
  if ($defaults = features_get_default('config_pages', $module)) {
    foreach ($defaults as $key => $default) {
      $data = explode('-', $key);
      $type = array_shift($data);
      $context = implode('-', $data);

      // Prepare destination config.
      $config = config_pages_load_entity($type, $context);
      if (empty($config)) {
        $config = config_pages_create(array(
          'type' => $type,
        ));
      }

      // Replace old values with new ones.
      $config = _config_pages_features_import_data('config_pages', $config, $default);

      // Allow other modules to add support for complex data.
      drupal_alter('config_pages_features_rebuild', $config, $default);

      // Update config.
      config_pages_save($config);
    }
  }
}