You are here

function lingotek_get_bundles_by_profile_id in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lingotek.util.inc \lingotek_get_bundles_by_profile_id()
  2. 7.6 lingotek.util.inc \lingotek_get_bundles_by_profile_id()
3 calls to lingotek_get_bundles_by_profile_id()
lingotek_admin_profile_usage_by_types in ./lingotek.admin.inc
lingotek_get_all_entities_by_profile in ./lingotek.util.inc
lingotek_get_entities_by_profile_and_entity_type in ./lingotek.util.inc

File

./lingotek.util.inc, line 1439
Utility functions.

Code

function lingotek_get_bundles_by_profile_id($profile_id) {
  $bundles = array();
  if (is_array($profile_id)) {

    // allow profile_ids to be an array of profiles to find bundles for
    $mapped_results = array_map('lingotek_get_bundles_by_profile_id', $profile_id);
    foreach ($mapped_results as $result) {
      $bundles = array_merge_recursive($result, $bundles);
    }
    return $bundles;
  }
  $entities = entity_get_info();
  $lentities = variable_get('lingotek_entity_profiles');
  foreach ($entities as $entity_name => $entity) {
    if (!isset($lentities[$entity_name])) {
      unset($entities[$entity_name]);
    }
    foreach ($entity['bundles'] as $bundle_name => $bundle) {
      if (isset($lentities[$entity_name][$bundle_name]) && $lentities[$entity_name][$bundle_name] === (string) $profile_id) {
        if (!isset($bundles[$entity_name])) {
          $bundles[$entity_name] = array();
        }
        $bundles[$entity_name][$bundle_name] = TRUE;
      }
    }
  }
  return $bundles;
}