You are here

function uuid_panelizer_features_export in UUID Features Integration 7

Implements hook_features_export().

File

includes/uuid_panelizer.features.inc, line 44
Features hooks for the panelizer features component.

Code

function uuid_panelizer_features_export($data, &$export, $module_name = '') {
  $pipe = array();
  $export['dependencies']['uuid_features'] = 'uuid_features';
  $export['dependencies']['panelizer'] = 'panelizer';
  foreach ($data as $key) {
    $exploded_key = explode(':', $key);
    if (count($exploded_key) < 3) {
      continue;
    }
    list($entity_type, $entity_uuid, $view_mode) = $exploded_key;
    $entity = entity_uuid_load($entity_type, array(
      $entity_uuid,
    ), array(), TRUE);
    $entity = reset($entity);

    // Only export the display if the related entity exists and its a modified
    // display with an uuid.
    if ($entity === FALSE || empty($entity->panelizer[$view_mode]->did) || empty($entity->panelizer[$view_mode]->display->uuid)) {
      continue;
    }
    $panelizer_settings = $entity->panelizer[$view_mode];
    $export['features']['uuid_panelizer'][$key] = $key;

    // Add dependencies to known uuid entity type exports.
    $uuid_features_entity_types = array(
      'taxonomy_term' => 'uuid_term',
      'node' => 'uuid_node',
      'user' => 'uuid_user',
    );
    if (isset($uuid_features_entity_types[$entity_type])) {
      $export['features'][$uuid_features_entity_types[$entity_type]][$entity_uuid] = $entity_uuid;
    }
    $data =& $export;
    $data['__drupal_alter_by_ref']['pipe'] =& $pipe;
    drupal_alter('uuid_panelizer_features_export', $data, $panelizer_settings, $module_name);
    unset($data['__drupal_alter_by_ref']);
  }
  return $pipe;
}