You are here

function uuid_bean_features_export_options in UUID Features Integration 7

Implements hook_features_export_options().

File

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

Code

function uuid_bean_features_export_options() {
  $options = array();

  // Check what bean types are enabled for uuid features export.
  $types = array();
  $entity_info = entity_get_info('bean');
  foreach ($entity_info['bundles'] as $key => $value) {
    if (variable_get("uuid_features_entity_bean_{$key}", FALSE)) {
      $types[$key] = $key;
    }
  }
  if (module_exists("bean_uuid") && !empty($types)) {
    $query = db_select('bean', 'n');
    $query
      ->fields('n', array(
      'bid',
      'delta',
      'type',
      'uuid',
    ))
      ->condition('type', $types)
      ->orderBy('type')
      ->orderBy('delta', 'ASC')
      ->addTag('uuid_bean_features_export_options');
    $beans = $query
      ->execute()
      ->fetchAll();
    foreach ($beans as $bean) {
      $options[$bean->uuid] = t('@type: @delta', array(
        '@type' => $bean->type,
        '@delta' => $bean->delta,
      ));
    }
  }
  drupal_alter('uuid_bean_features_export_options', $options);
  return $options;
}