You are here

function uuid_bean_features_export_render in UUID Features Integration 7

Implements hook_features_export_render().

File

includes/uuid_bean.features.inc, line 97
Features UUID integration for BEAN instances.

Code

function uuid_bean_features_export_render($module, $data) {
  $translatables = $code = array();
  $code[] = '  $beans = array();';
  $code[] = '';
  foreach ($data as $uuid) {
    $beans = entity_uuid_load('bean', array(
      $uuid,
    ), array(), TRUE);
    if (!count($beans)) {
      continue;
    }
    $first_bean = reset($beans);

    // Clone entity to avoid changes by reference.
    $export = clone $first_bean;

    // Unset some things that dont need to be exported.
    unset($export->bid);
    unset($export->rdf_mapping);
    unset($export->changed);
    unset($export->vid);

    // Enable file field exports.
    uuid_features_file_field_export($export, 'bean');
    $entity_type = 'bean';
    drupal_alter('uuid_entity_features_export_render', $entity_type, $export, $first_bean, $module);
    drupal_alter('uuid_bean_features_export_render', $export, $first_bean, $module);
    $json = json_encode($export);
    $export_array = json_decode($json, TRUE);
    $code[] = '  $beans[] = ' . features_var_export($export_array, '  ') . ';';
  }
  if (!empty($translatables)) {
    $code[] = features_translatables_export($translatables, '  ');
  }
  $code[] = '  return $beans;';
  $code = implode("\n", $code);
  return array(
    'uuid_features_default_beans' => $code,
  );
}