You are here

function commons_media_system_info_alter in Drupal Commons 7.3

Implements hook_system_info_alter().

File

modules/commons/commons_media/commons_media.module, line 15

Code

function commons_media_system_info_alter(&$info, $file, $type) {
  if ($file->name == 'commons_media') {
    $entity_integrations = commons_entity_integration_info();
    if (!empty($entity_integrations)) {
      foreach ($entity_integrations as $entity_type => $bundles) {
        foreach ($bundles as $bundle => $integrations) {
          if (!empty($integrations['media'])) {
            $info['features']['field_instance'][] = "{$entity_type}-{$bundle}-field_media";
          }
        }
      }
    }
  }

  // Dynamically adding a field instance to an entity type results in features
  // automatically detecting Commons Media as a dependency.
  // We manually exclude the dependency in order to prevent entity type provider
  // modules from appearing overridden and to allow them to be used
  // independently of Commons Media.
  $commons_entity_integrations =& drupal_static(__FUNCTION__);
  if (!isset($commons_entity_integrations)) {
    foreach (module_implements('commons_entity_integration') as $module) {
      $commons_entity_integrations[$module] = call_user_func($module . '_commons_entity_integration');
    }
  }
  if (isset($commons_entity_integrations[$file->name])) {
    foreach ($commons_entity_integrations[$file->name] as $entity_type => $integration) {
      foreach ($integration as $bundle => $options) {
        if (commons_media_has_media_integration($entity_type, $bundle)) {
          $info['features_exclude']['dependencies']['commons_media'] = 'commons_media';
        }
      }
    }
  }
}