You are here

function uuid_bean_features_export in UUID Features Integration 7

Implements hook_features_export().

File

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

Code

function uuid_bean_features_export($data, &$export, $module_name = '') {
  $pipe = array();
  $export['dependencies']['bean'] = 'bean';
  $export['dependencies']['bean_uuid'] = 'bean_uuid';
  $export['dependencies']['uuid_features'] = 'uuid_features';
  $bids = entity_get_id_by_uuid('bean', $data);
  foreach ($bids as $uuid => $bid) {

    // Load the bean matching the $bid.
    $query = new EntityFieldQuery();
    $beans = $query
      ->entityCondition('entity_type', 'bean')
      ->propertyCondition('bid', $bid)
      ->range(0, 1)
      ->execute();
    $export['features']['uuid_bean'][$uuid] = $uuid;
    $bean = $beans['bean'][$bid];
    $pipe['bean'][$bean->type] = $bean->type;

    // Check for additional bean plugin module dependencies.
    foreach (module_implements('bean_types') as $module) {
      $result = call_user_func_array($module . '_bean_types', array());
      if (isset($result) && is_array($result)) {
        foreach ($result as $type => $values) {
          if ($type == $bean->type) {
            $export['dependencies'][$module] = $module;
          }
        }
      }
    }

    // drupal_alter() normally supports just one byref parameter. Using
    // the __drupal_alter_by_ref key, we can store any additional parameters
    // that need to be altered, and they'll be split out into additional params
    // for the hook_*_alter() implementations.  The hook_alter signature is
    // hook_uuid_bean_features_export_alter(&$export, &$pipe, $bean).
    $data =& $export;
    $data['__drupal_alter_by_ref']['pipe'] =& $pipe;
    $entity_type = 'bean';
    drupal_alter('uuid_entity_features_export', $entity_type, $data, $bean, $module);
    drupal_alter('uuid_bean_features_export', $data, $bean, $module);
    unset($data['__drupal_alter_by_ref']);
  }
  return $pipe;
}