function lingotek_get_bundles_by_profile_id in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_get_bundles_by_profile_id()
- 7.6 lingotek.util.inc \lingotek_get_bundles_by_profile_id()
3 calls to lingotek_get_bundles_by_profile_id()
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;
}