You are here

function _uuid_fpp_features_dependencies in UUID Features Integration 7

Discovers modules which affect the FPP bundle info for dependency mapping.

1 call to _uuid_fpp_features_dependencies()
uuid_fpp_features_export in includes/uuid_fpp.features.inc
Implements hook_features_export().

File

includes/uuid_fpp.features.inc, line 174
Features hooks for the uuid_fpp features component.

Code

function _uuid_fpp_features_dependencies($uuids) {
  $implements = array();
  $entity_info = array();
  $bundles = array();
  foreach (entity_uuid_load('fieldable_panels_pane', $uuids, array(), TRUE) as $entity) {
    list(, , $bundle) = entity_extract_ids('fieldable_panels_pane', $entity);
    $bundles[$bundle] = $bundle;
  }

  // Check for modules that affect the bundle info of the given entity's bundle.
  foreach (module_implements('entity_info') as $module) {
    $result = module_invoke($module, 'entity_info');
    foreach ($bundles as $bundle) {
      if (isset($result['fieldable_panels_pane']['bundles'][$bundle])) {
        $implements[$module] = $module;
      }
      if (isset($result) && is_array($result)) {
        $entity_info = array_replace_recursive($entity_info, $result);
      }
    }
  }
  foreach ($entity_info as $name => $data) {
    $entity_info[$name] += array(
      'fieldable' => FALSE,
      'controller class' => 'DrupalDefaultEntityController',
      'static cache' => TRUE,
      'field cache' => TRUE,
      'load hook' => $name . '_load',
      'bundles' => array(),
      'view modes' => array(),
      'entity keys' => array(),
      'translation' => array(),
    );
    $entity_info[$name]['entity keys'] += array(
      'revision' => '',
      'bundle' => '',
    );
    foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
      $entity_info[$name]['view modes'][$view_mode] += array(
        'custom settings' => FALSE,
      );
    }

    // If no bundle key is provided, assume a single bundle, named after
    // the entity type.
    if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
      $entity_info[$name]['bundles'] = array(
        $name => array(
          'label' => $entity_info[$name]['label'],
        ),
      );
    }

    // Prepare entity schema fields SQL info for
    // DrupalEntityControllerInterface::buildQuery().
    if (isset($entity_info[$name]['base table'])) {
      $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
      if (isset($entity_info[$name]['revision table'])) {
        $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
      }
    }
  }

  // Discover all modules which implement entity_info_alter.
  foreach (module_implements('entity_info_alter') as $module) {
    $function = $module . '_entity_info_alter';
    if (function_exists($function)) {

      // Keep a backup of the FPP entity info so we can compare it later.
      $backup = $entity_info['fieldable_panels_pane']['bundles'];
      $function($entity_info);
      foreach ($bundles as $bundle) {

        // Check if the module changes anything in the entity info.
        if (isset($backup[$bundle]) && !isset($entity_info['fieldable_panels_pane']['bundles'][$bundle])) {
          $implements[$module] = $module;
        }
        elseif ($backup[$bundle] != $entity_info['fieldable_panels_pane']['bundles'][$bundle]) {
          $implements[$module] = $module;
        }
      }
    }
  }
  return $implements;
}