You are here

function uuid_paragraphs_features_export_options in UUID Features Integration 7

Implements hook_features_export_options().

File

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

Code

function uuid_paragraphs_features_export_options() {
  $options = array();
  $all_ids = array();
  $enabled_bundles = array();
  $entity_info = entity_get_info('paragraphs_item');
  foreach ($entity_info['bundles'] as $key => $value) {

    // Only allow enabled bundles to be exported.
    if (variable_get("uuid_features_entity_paragraphs_item_{$key}", FALSE)) {
      $enabled_bundles[] = $key;
    }
  }
  if ($enabled_bundles) {
    $efq_paragraphs_items = new EntityFieldQuery();
    $efq_paragraphs_items
      ->entityCondition('entity_type', 'paragraphs_item');
    $efq_paragraphs_items
      ->entityCondition('bundle', $enabled_bundles);
    $efq_paragraphs_items
      ->addTag('uuid_paragraphs_features_export_options');
    $result = $efq_paragraphs_items
      ->execute();
    if (!empty($result['paragraphs_item'])) {
      $all_ids = array_keys($result['paragraphs_item']);
    }
    $items = entity_load('paragraphs_item', $all_ids);
    foreach ($items as $item) {
      $info = $item
        ->instanceInfo();
      $options[$item->uuid] = t('@type: @title', array(
        '@type' => $info['label'] . " Field",
        '@title' => $item->bundle . " - " . $item->item_id,
      ));
    }
  }
  drupal_alter('uuid_paragraphs_features_export_options', $options);
  return $options;
}