You are here

function uuid_paragraphs_features_export_render in UUID Features Integration 7

Implements hook_features_export_render().

File

includes/uuid_paragraphs.features.inc, line 66
Features hooks for the uuid_paragraphs features component.

Code

function uuid_paragraphs_features_export_render($module, $data) {
  $translatables = $code = $return = array();
  $code[] = '  $paragraphs = array();';
  $code[] = '';
  foreach ($data as $uuid) {
    $paragraphs = entity_uuid_load('paragraphs_item', array(
      $uuid,
    ), array(), TRUE);
    if (!count($paragraphs)) {
      continue;
    }
    $paragraph = reset($paragraphs);

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

    // Do not export ids.
    unset($export->item_id);
    unset($export->revision_id);
    $files = uuid_features_file_field_export($export, 'paragraphs_item');
    $entity_type = 'paragraphs_item';
    drupal_alter('uuid_entity_features_export_render', $entity_type, $export, $paragraph, $module);
    $code[] = '  $paragraphs[] = ' . features_var_export(get_object_vars($export), '  ') . ';';

    // Add packaged files, if any.
    if (!empty($files)) {
      foreach ($files as $filename => $src_path) {
        $return[$filename] = $src_path;
      }
    }
  }
  if (!empty($translatables)) {
    $code[] = features_translatables_export($translatables, '  ');
  }
  $code[] = '  return $paragraphs;';
  $code = implode("\n", $code);
  $return['uuid_features_default_paragraphs'] = $code;
  return $return;
}