You are here

function schemaorg_features_export_render in Schema.org 7

Implementation of hook_features_export_render().

Renders a set of components to code as a defaults hook.

File

./schemaorg.features.inc, line 48

Code

function schemaorg_features_export_render($module, $data, $export = NULL) {
  $code = array();
  $code[] = '  $schemaorg = array();';
  $code[] = '';
  foreach ($data as $key => $entity_type_bundle) {
    if (is_array($entity_type_bundle)) {
      $entity_type_bundle = $key;
    }
    $parts = explode('-', $entity_type_bundle);
    $entity_type = $parts[0];
    $bundle_name = $parts[1];
    if ($rdf_mapping = rdf_mapping_load($entity_type, $bundle_name)) {
      $rdf_mapping_export = features_var_export($rdf_mapping, '  ');
      $rdf_bundle = features_var_export($bundle_name);
      $rdf_entity_type = features_var_export($entity_type);
      $code[] = "  // Exported RDF mapping: {$bundle_name}";
      $code[] = "  \$schemaorg[{$rdf_entity_type}][{$rdf_bundle}] = {$rdf_mapping_export};";
      $code[] = "";
    }
  }
  $code[] = '  return $schemaorg;';
  $code = implode("\n", $code);
  return array(
    'rdf_default_mappings' => $code,
  );
}