You are here

function hansel_export_config in Hansel breadcrumbs 8

Same name and namespace in other branches
  1. 7 hansel.export.inc \hansel_export_config()

Export Hansel configuration.

Return value

array

1 call to hansel_export_config()
hansel_features_export_render in ./hansel.features.inc
Implements hook_features_export_render().

File

./hansel.export.inc, line 8

Code

function hansel_export_config() {
  $config = hansel_get_config();
  $mapping = array();
  $export = array(
    'version' => $config['version'],
    'start_rid' => 0,
    'rules' => array(),
    'nodetypes' => $config['nodetypes'],
  );

  // Copy rules and renumber them.
  $id = 0;
  foreach ($config['rules'] as $rule) {
    ++$id;
    $mapping[$rule->rid] = $id;
    $rule->rid = $id;
    $export['rules'][$id] = clone $rule;
  }

  // Map start rule.
  $export['start_rid'] = $mapping[$config['start_rid']];

  // Map parents and destinations.
  foreach ($export['rules'] as $id => $rule) {
    if ($rule->pid) {
      $export['rules'][$id]->pid = $mapping[$rule->pid];
    }
    if ($rule->action == 'goto') {
      $export['rules'][$id]->destination = $mapping[$rule->destination];
    }
  }
  return $export;
}