function oa_related_preprocess_entity in Open Atrium Related Content 7.2
Implements hook_preprocess_HOOK().
Pre-process theme variables for various paragraph item types.
File
- ./
oa_related.module, line 466
Code
function oa_related_preprocess_entity(&$vars) {
if ($vars['entity_type'] == 'paragraphs_item') {
$field_name = NULL;
$info = oa_related_get_paragraph_field_info();
$value = NULL;
$paragraph_wrapper = entity_metadata_wrapper('paragraphs_item', $vars['paragraphs_item']);
$vars['oa_related_content'] = '';
foreach ($info as $field_name => $bundle) {
foreach ($bundle as $bundle_name => $data) {
if ($paragraph_wrapper->bundle
->value() == $bundle_name) {
if (isset($paragraph_wrapper->{$field_name})) {
$value = $paragraph_wrapper->{$field_name}
->value();
}
if (isset($data['render callback'])) {
if (is_array($data['render callback'])) {
foreach ($data['render callback'] as $function) {
if (function_exists($function)) {
// Call the function that will allow pre-processing for this layout selection.
$function($vars, $bundle_name, $field_name, $value);
// This allows other modules to alter the '$variables' array after we are done with it. If you want to
// completely override it then use drupal_alter: "hook_oa_related_field_info_alter()" and
// replace the 'render callback'.
drupal_alter($function, $vars, $bundle_name, $field_name, $value);
}
}
}
else {
$function = $data['render callback'];
if (function_exists($function)) {
// Call the function that will allow pre-processing for this layout selection.
$function($vars, $bundle_name, $field_name, $value);
// This allows other modules to alter the '$variables' array after we are done with it. If you want to
// completely override it then use drupal_alter: "hook_oa_related_field_info_alter()" and
// replace the 'render callback'.
drupal_alter($function, $vars, $bundle_name, $field_name, $value);
}
}
}
}
}
}
}
}