Added Case Provision entity for recording caseworker involvement with cases

This commit is contained in:
2021-11-11 08:39:18 +00:00
parent 6dca2e98e9
commit f601890ad0
34 changed files with 2179 additions and 3 deletions

View File

@ -40,8 +40,18 @@ function opencase_cases_theme() {
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case.page.inc',
],
'oc_case_provision' => [
'render element' => 'elements',
'file' => 'oc_case_provision.page.inc',
'template' => 'oc_case_provision',
]
];
$theme['oc_case_provision_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case_provision.page.inc',
];
}
function opencase_cases_entity_base_field_info($entity_type) {
@ -56,7 +66,7 @@ function opencase_cases_entity_base_field_info($entity_type) {
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setDefaultValueCallback('opencase_cases_default_activity_case_value')
->setDefaultValueCallback('opencase_cases_default_case_id')
->setDisplayOptions('view', [
'type' => 'string',
'weight' => -3,
@ -69,7 +79,7 @@ function opencase_cases_entity_base_field_info($entity_type) {
/**
* When creating an activity, it sets the case id from the URL.
*/
function opencase_cases_default_activity_case_value() {
function opencase_cases_default_case_id() {
return array(\Drupal::request()->query->get('case_id'));
}
@ -138,3 +148,20 @@ function opencase_cases_theme_suggestions_oc_case(array $variables) {
// $query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
//}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_cases_theme_suggestions_oc_case_provision(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_case_provision'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_case_provision__' . $sanitized_view_mode;
$suggestions[] = 'oc_case_provision__' . $entity->bundle();
$suggestions[] = 'oc_case_provision__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_case_provision__' . $entity->id();
$suggestions[] = 'oc_case_provision__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}