function scald_context_type_features_rebuild in Scald: Media Management made easy 7
Implements hook_features_rebuild().
1 call to scald_context_type_features_rebuild()
- scald_context_type_features_revert in ./
scald.features.inc - Implements hook_features_revert().
File
- ./
scald.features.inc, line 92 - File name: scald.features.inc.
Code
function scald_context_type_features_rebuild($module) {
$contexts = module_invoke($module, 'scald_default_context_types');
$regroup = array();
// Get default contexts and regroup by type.
foreach ($contexts as $key => $context) {
$context_name = _scald_context_type_extract($key, 'context');
// Ensure there's at least a stub for each of the exported properties.
$context = array_merge_recursive($context, array(
'player' => array(),
'transcoder' => array(),
'data' => array(),
));
if (!isset($regroup[$context_name])) {
// Initialize this context.
$regroup[$context_name] = $context;
}
else {
// Merge types data.
$regroup[$context_name]['player'] = array_merge_recursive($regroup[$context_name]['player'], $context['player']);
$regroup[$context_name]['transcoder'] = array_merge_recursive($regroup[$context_name]['transcoder'], $context['transcoder']);
$regroup[$context_name]['data'] = array_merge_recursive($regroup[$context_name]['data'], $context['data']);
}
}
// Once whole contexts are regrouped.
foreach ($regroup as $name => $data) {
$config = scald_context_config_load($name);
foreach (scald_types() as $type) {
if (isset($data['transcoder'][$type->type])) {
$config->transcoder[$type->type] = $data['transcoder'][$type->type];
}
if (isset($data['player'][$type->type])) {
$config->player[$type->type] = $data['player'][$type->type];
}
// At this point data is per-context, not per-context-per-bundle so this
// is a little redundant to store on every bundle. But if #2600088 is
// resolved then this framework should support existing exports without
// needing to change.
if (isset($data['data'][$type->type])) {
$config->data = $data['data'][$type->type];
}
}
scald_context_config_save($config);
}
cache_clear_all('*', 'cache_scald', TRUE);
}