This repository has been archived on 2022-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
opencase/modules/opencase_cases/oc_case.page.inc

41 lines
1.5 KiB
PHP
Raw Normal View History

2018-04-29 11:58:46 +00:00
<?php
/**
* @file
* Contains oc_case.page.inc.
*
* Page callback for Case entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Case templates.
*
* Default template: oc_case.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_oc_case(array &$variables) {
// Separate the fields into two sections to be displayed in two columns.
// Remove the name (title) field as this is displayed anyway.
$variables['id'] = $variables['elements']['#oc_case']->get('id')[0]->get('value')->getValue();
$variables['eva_fields'] = array(); // if the installation has any "EVA" (embedded view) fields this should catch them.
$variables['base_fields'] = array();
$variables['other_fields'] = array();
2018-04-29 11:58:46 +00:00
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
if (in_array($key, ['created', 'changed', 'files', 'actors_involved', 'status', 'user_id'])) {
$variables['base_fields'][$key] = $variables['elements'][$key];
} else if (strpos($key, "entity_view") !== false) {
$variables['eva_fields'][$key] = $variables['elements'][$key];
} else {
$variables['other_fields'][$key] = $variables['elements'][$key];
unset($variables['other_fields']['name']);
}
2018-04-29 11:58:46 +00:00
}
}