Added target field to case, and added fee category vocab to opencase config

This commit is contained in:
naomi 2022-04-03 17:31:00 +01:00
parent c3f802835f
commit 167166b898
5 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,8 @@
uuid: 93a96bb4-da95-4d69-be37-d1477624f849
langcode: en
status: true
dependencies: { }
name: 'Fee categories'
vid: oc_fee_category
description: ''
weight: 0

View File

@ -1,4 +1,20 @@
<?php
use \Drupal\Core\Field\BaseFieldDefinition;
function opencase_cases_update_90002() {
$field_storage_definition = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Target'))
->setRevisionable(TRUE)
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('oc_target', 'oc_case', 'opencase_cases', $field_storage_definition);
}
function opencase_cases_update_8025() {
//check if the table exists first. If not, then create the entity.
@ -10,7 +26,7 @@ function opencase_cases_update_8025() {
}
function opencase_cases_update_8026() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
$storage_definition = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Role'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['oc_case_provider_role' => 'oc_case_provider_role']])

View File

@ -89,6 +89,12 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
];
}
public static function defaultTarget() {
if (opencase_entities_get('target_id')) return [opencase_entities_get('target_id')];
else return [];
}
/**
* {@inheritdoc}
*/
@ -202,6 +208,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
return $this;
}
/**
* {@inheritdoc}
*/
@ -230,6 +238,17 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
'type' => 'author',
'weight' => 80,
]);
$fields['oc_target'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Target'))
->setRevisionable(TRUE)
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setDefaultValueCallback('\Drupal\opencase_cases\Entity\OCCase::defaultTarget')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
->setRevisionable(TRUE)

View File

@ -91,7 +91,7 @@ function opencase_entities_theme() {
* 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);
return \Drupal::request()->query->get($key);
}
/**

View File

@ -63,6 +63,20 @@ opencase.manage_activity_types:
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_activity_type
weight: 3
opencase.manage_case_fee_types:
title: 'Manage case fee types'
description: 'Configure types of case fees and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_case_fee_type
weight: 3
opencase.manage_case_provision_types:
title: 'Manage case provision types'
description: 'Configure types of case provisions and their fields'
menu_name: opencase
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_case_provision_type
weight: 3
opencase.manage_event_types:
title: 'Manage event types'
description: 'Configure types of people and their fields'