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_entities/opencase_entities.module

178 lines
5.8 KiB
Plaintext
Raw Normal View History

<?php
/**
* @file
* Contains opencase_entities.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\opencase_entities\CaseInvolvement;
/**
* Implements hook_help().
*/
function opencase_entities_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the opencase_entities module.
case 'help.page.opencase_entities':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
2018-04-29 11:52:36 +00:00
$output .= '<p>' . t('Entity Types for OpenCase') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function opencase_entities_theme() {
2018-04-29 11:58:46 +00:00
$theme = [];
$theme['oc_organisation_relation'] = [
'render element' => 'elements',
'file' => 'oc_organisation_relation.page.inc',
'template' => 'oc_organisation_relation',
];
$theme['oc_organisation_relation_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_organisation_relation.page.inc',
];
2018-04-29 11:58:46 +00:00
$theme['opencase_entities'] = [
'render element' => 'children',
];
2018-04-29 11:58:46 +00:00
$theme['oc_actor'] = [
'render element' => 'elements',
'file' => 'oc_actor.page.inc',
'template' => 'oc_actor',
];
$theme['oc_actor_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_actor.page.inc',
];
$theme['oc_activity'] = [
'render element' => 'elements',
'file' => 'oc_activity.page.inc',
'template' => 'oc_activity',
];
$theme['oc_activity_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'template' => 'oc-activity-content-add-list',
2018-04-29 11:58:46 +00:00
'file' => 'oc_activity.page.inc',
];
2020-11-12 17:13:28 +00:00
$theme['oc_organisation'] = [
'render element' => 'elements',
'file' => 'oc_organisation.page.inc',
'template' => 'oc_organisation',
];
$theme['oc_organisation_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_organisation.page.inc',
];
2021-01-28 10:22:20 +00:00
$theme['oc_event'] = [
'render element' => 'elements',
'file' => 'oc_event.page.inc',
'template' => 'oc_event',
];
$theme['oc_event_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_event.page.inc',
];
2018-04-29 11:58:46 +00:00
return $theme;
}
2022-04-03 13:37:40 +00:00
/**
* Get the value of a url parameter and return it in a array
* so that it can be used as a default callback for an entity reference field.
*/
function opencase_entities_get($key) {
\Drupal::request()->query->get($key);
}
2018-04-29 11:58:46 +00:00
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_actor(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_actor'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_actor__' . $sanitized_view_mode;
$suggestions[] = 'oc_actor__' . $entity->bundle();
$suggestions[] = 'oc_actor__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_actor__' . $entity->id();
$suggestions[] = 'oc_actor__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_activity(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_activity'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_activity__' . $sanitized_view_mode;
$suggestions[] = 'oc_activity__' . $entity->bundle();
$suggestions[] = 'oc_activity__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_activity__' . $entity->id();
$suggestions[] = 'oc_activity__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
2020-11-12 17:13:28 +00:00
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_organisation(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_organisation'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_organisation__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation__' . $entity->bundle();
$suggestions[] = 'oc_organisation__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation__' . $entity->id();
$suggestions[] = 'oc_organisation__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
2021-01-28 10:22:20 +00:00
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_event(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_event'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_event__' . $sanitized_view_mode;
$suggestions[] = 'oc_event__' . $entity->bundle();
$suggestions[] = 'oc_event__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_event__' . $entity->id();
$suggestions[] = 'oc_event__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_organisation_relation(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_organisation_relation'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_organisation_relation__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation_relation__' . $entity->bundle();
$suggestions[] = 'oc_organisation_relation__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_organisation_relation__' . $entity->id();
$suggestions[] = 'oc_organisation_relation__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}