You are here

function panelizer_uuid_entity_features_export_alter in UUID Features Integration 7

Implements hook_uuid_entity_features_export_alter().

File

includes/modules/panelizer.inc, line 10
uuid features hooks on behalf of the panelizer module.

Code

function panelizer_uuid_entity_features_export_alter($entity_type, &$data, $entity, $module) {
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  if (!$handler) {
    return;
  }
  if (panelizer_is_panelized($handler, $bundle) && !empty($entity->panelizer)) {

    // Access / modify the pipe.
    $pipe =& $data['__drupal_alter_by_ref']['pipe'];
    foreach ($entity->panelizer as $view_mode => $panelize_settings) {

      // If there's no uuid - skip the whole action.
      if (empty($panelize_settings->display->uuid)) {
        continue;
      }

      // Check if to export or not.
      switch (TRUE) {

        // If the settings are already exported, add dependency to the module.
        case isset($panelize_settings->export_module):
          $pipe['dependencies'][$panelize_settings->export_module] = $panelize_settings->export_module;
          break;

        // Add dependency to the panelizer default configuration.
        case isset($panelize_settings->name):
          $data['features']['panelizer_defaults'][$panelize_settings->name] = $panelize_settings->name;
          break;

        // If this is a modified display add dependency to uuid panelizer.
        case !empty($panelize_settings->entity_id) && !empty($panelize_settings->did):
          $export_key = $entity_type . ':' . $entity->uuid . ':' . $view_mode;
          $data['features']['uuid_panelizer'][$export_key] = $export_key;
          break;
      }
    }
  }
}