Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase

This commit is contained in:
naomi 2022-05-11 13:48:11 +01:00
commit 6dcd379535
15 changed files with 105 additions and 961 deletions

View File

@ -0,0 +1,29 @@
uuid: 22782d1b-4b5d-422e-9609-96e63ffd39da
langcode: en
status: true
dependencies:
config:
- views.view.cases
module:
- route_condition
- views
theme:
- bartik
id: views_block__cases_block_1
theme: bartik
region: content
weight: 0
provider: null
plugin: 'views_block:cases-block_1'
settings:
id: 'views_block:cases-block_1'
label: ''
label_display: visible
provider: views
views_label: ''
items_per_page: none
visibility:
route:
id: route
negate: false
routes: entity.oc_actor.canonical

View File

@ -3,25 +3,12 @@ langcode: en
status: true
dependencies:
config:
- field.field.oc_case_provision.caseworker.field_test
- opencase_cases.oc_case_provision_type.caseworker
module:
- hide_revision_field
id: oc_case_provision.caseworker.default
targetEntityType: oc_case_provision
bundle: caseworker
mode: default
content:
field_test:
type: entity_reference_autocomplete
weight: 81
region: content
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
oc_case:
type: entity_reference_autocomplete
weight: 0

View File

@ -17,36 +17,31 @@ dependencies:
- field.field.oc_actor.client.field_marital_
- field.field.oc_actor.client.field_nationalities
- field.field.oc_actor.client.field_referred_by
- field.field.oc_actor.client.field_sex
- opencase_entities.oc_actor_type.client
module:
- datetime
- file
- options
- user
id: oc_actor.client.default
targetEntityType: oc_actor
bundle: client
mode: default
content:
cases:
settings: { }
third_party_settings: { }
weight: 19
region: content
email:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
weight: -5
region: content
field_asylum_status:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 8
weight: 3
region: content
field_client_field_1:
type: string
@ -62,7 +57,7 @@ content:
settings:
use_description_as_link_text: true
third_party_settings: { }
weight: 17
weight: 12
region: content
field_date_of_birth:
type: datetime_default
@ -71,7 +66,7 @@ content:
timezone_override: ''
format_type: short
third_party_settings: { }
weight: 5
weight: 0
region: content
field_dependants:
type: string
@ -79,7 +74,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 14
weight: 9
region: content
field_disability:
type: string
@ -87,7 +82,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 12
weight: 7
region: content
field_ethnic_o:
type: string
@ -95,56 +90,56 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 9
weight: 4
region: content
field_gender_identified_with:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 6
weight: 1
region: content
field_general_noes:
type: basic_string
label: above
settings: { }
third_party_settings: { }
weight: 18
weight: 13
region: content
field_how_heard:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 15
weight: 10
region: content
field_income:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 13
weight: 8
region: content
field_languages_spoken:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 11
weight: 6
region: content
field_marital_:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 7
weight: 2
region: content
field_nationalities:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 10
weight: 5
region: content
field_referred_by:
type: string
@ -152,7 +147,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 16
weight: 11
region: content
name:
type: string
@ -168,7 +163,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 1
weight: -4
region: content
phone2:
type: string
@ -176,7 +171,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 2
weight: -3
region: content
post_code:
type: string
@ -184,14 +179,14 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 4
weight: -1
region: content
postal_address:
type: basic_string
label: above
settings: { }
third_party_settings: { }
weight: 3
weight: -2
region: content
hidden:
field_sex: true
@ -199,5 +194,3 @@ hidden:
last_name: true
middle_names: true
search_api_excerpt: true
status: true
user_id: true

View File

@ -23,7 +23,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
weight: -5
region: content
field_ethnic_o:
type: string
@ -31,35 +31,35 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 10
weight: 6
region: content
field_general_noes:
type: basic_string
label: above
settings: { }
third_party_settings: { }
weight: 9
weight: 5
region: content
field_languages_spoken:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 6
weight: 2
region: content
field_nationalities:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 5
weight: 1
region: content
field_osic_level:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 7
weight: 3
region: content
field_sdfdsfds:
type: text_default
@ -73,7 +73,7 @@ content:
label: above
settings: { }
third_party_settings: { }
weight: 8
weight: 4
region: content
name:
type: string
@ -89,7 +89,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 1
weight: -4
region: content
phone2:
type: string
@ -97,7 +97,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 2
weight: -3
region: content
post_code:
type: string
@ -105,28 +105,17 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 4
weight: -1
region: content
postal_address:
type: basic_string
label: above
settings: { }
third_party_settings: { }
weight: 3
region: content
total_cases:
type: number_integer
label: above
settings:
thousand_separator: ''
prefix_suffix: true
third_party_settings: { }
weight: 11
weight: -2
region: content
hidden:
first_name: true
last_name: true
middle_names: true
search_api_excerpt: true
status: true
user_id: true

View File

@ -3,7 +3,6 @@ langcode: en
status: true
dependencies:
config:
- field.field.oc_case_provision.caseworker.field_test
- opencase_cases.oc_case_provision_type.caseworker
module:
- user
@ -12,14 +11,6 @@ targetEntityType: oc_case_provision
bundle: caseworker
mode: default
content:
field_test:
type: entity_reference_label
label: above
settings:
link: true
third_party_settings: { }
weight: 4
region: content
oc_case_provider_role:
type: entity_reference_label
label: above

View File

@ -1,44 +0,0 @@
uuid: 76bf5d8f-6a61-417b-9de2-43cf77890abb
langcode: en
status: true
dependencies:
config:
- system.menu.opencase
- user.role.authenticated
module:
- opencase_cases
- user
id: oc_actor.client.cases
label: Cases
display_label: true
name: cases
description: ''
base_entity_type_id: oc_actor
base_bundle_type_id: client
field_type_id: views
field_type_config:
view_name: cases
display: block_1
arguments: ''
field_type_condition:
'entity_bundle:oc_actor':
id: 'entity_bundle:oc_actor'
negate: false
context_mapping:
oc_actor: entity_extra_field.target_entity
bundles: { }
route:
id: route
negate: false
routes: ''
request_path:
id: request_path
negate: false
pages: ''
current_theme:
id: current_theme
theme: ''
negate: 0
field_conditions_all_pass: false
display:
type: view

View File

@ -1,53 +0,0 @@
uuid: 77781cfa-1449-4d3b-8e87-28b1eb760e14
langcode: en
status: true
dependencies:
config:
- opencase_cases.oc_case_provision_type.caseworker
- user.role.authenticated
module:
- opencase_cases
- user
id: oc_case.accommodation.caseworkers
label: Caseworkers
display_label: true
name: caseworkers
description: ''
base_entity_type_id: oc_case
base_bundle_type_id: accommodation
field_type_id: views
field_type_config:
view_name: case_provisions
display: block_2
arguments: ''
field_type_condition:
'entity_bundle:oc_case':
id: 'entity_bundle:oc_case'
negate: false
context_mapping:
oc_case: entity_extra_field.target_entity
bundles:
accommodation: accommodation
asylum_support: asylum_support
employability: employability
enquiry: enquiry
health: health
immigration: immigration
pro_bono_immigration_service: pro_bono_immigration_service
volunteer_engagement: volunteer_engagement
welfare_rights: welfare_rights
route:
id: route
negate: false
routes: ''
request_path:
id: request_path
negate: false
pages: ''
current_theme:
id: current_theme
theme: ''
negate: 0
field_conditions_all_pass: false
display:
type: view

View File

@ -1,31 +0,0 @@
uuid: 561fe652-6e6b-401a-a5d7-eef6402f6d07
langcode: en
status: true
dependencies:
config:
- field.storage.oc_case_provision.field_test
- opencase_cases.oc_case_provision_type.caseworker
- opencase_entities.oc_actor_type.staff_member
- opencase_entities.oc_actor_type.volunteer
id: oc_case_provision.caseworker.field_test
field_name: field_test
entity_type: oc_case_provision
bundle: caseworker
label: test
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:oc_actor'
handler_settings:
target_bundles:
staff_member: staff_member
volunteer: volunteer
sort:
field: _none
direction: ASC
auto_create: false
auto_create_bundle: staff_member
field_type: entity_reference

View File

@ -1,20 +0,0 @@
uuid: f90d1b9f-ee8a-4f79-ae7d-fafd4ec10cea
langcode: en
status: true
dependencies:
module:
- opencase_cases
- opencase_entities
id: oc_case_provision.field_test
field_name: field_test
entity_type: oc_case_provision
type: entity_reference
settings:
target_type: oc_actor
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -1,701 +0,0 @@
uuid: 00afe158-4881-4478-b808-06e2841efc36
langcode: en
status: true
dependencies:
config:
- opencase_cases.oc_case_provision_type.caseworker
- user.role.authenticated
module:
- opencase_cases
- user
id: case_provisions
label: 'Case provisions'
module: views
description: ''
tag: ''
base_table: oc_case_provision_field_data
base_field: id
display:
default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options:
title: 'Case provisions'
fields:
oc_case:
id: oc_case
table: oc_case_provision_field_data
field: oc_case
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case
plugin_id: field
label: Case
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
oc_case_provider_role:
id: oc_case_provider_role
table: oc_case_provision_field_data
field: oc_case_provider_role
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case_provider_role
plugin_id: field
label: Role
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
pager:
type: none
options:
offset: 0
items_per_page: null
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
access:
type: role
options:
role:
authenticated: authenticated
cache:
type: tag
options: { }
empty: { }
sorts: { }
arguments:
oc_provider:
id: oc_provider
table: oc_case_provision_field_data
field: oc_provider
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_provider
plugin_id: numeric
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: raw
default_argument_options:
index: 2
use_alias: false
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
override: false
items_per_page: 25
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
filters:
status:
id: status
table: oc_case_provision_field_data
field: status
entity_type: oc_case_provision
entity_field: status
plugin_id: boolean
value: '1'
group: 1
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
type:
id: type
table: oc_case_provision_field_data
field: type
entity_type: oc_case_provision
entity_field: type
plugin_id: bundle
value:
caseworker: caseworker
expose:
operator_limit_selection: false
operator_list: { }
style:
type: table
row:
type: fields
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
header: { }
footer: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user.roles
tags: { }
block_1:
id: block_1
display_title: 'By provider'
display_plugin: block
position: 1
display_options:
fields:
oc_case:
id: oc_case
table: oc_case_provision_field_data
field: oc_case
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case
plugin_id: field
label: Case
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
oc_case_provider_role:
id: oc_case_provider_role
table: oc_case_provision_field_data
field: oc_case_provider_role
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case_provider_role
plugin_id: field
label: Role
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
oc_target:
id: oc_target
table: oc_case_field_data
field: oc_target
relationship: oc_case
group_type: group
admin_label: ''
entity_type: oc_case
entity_field: oc_target
plugin_id: field
label: Target
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
defaults:
relationships: false
fields: false
relationships:
oc_case:
id: oc_case
table: oc_case_provision_field_data
field: oc_case
relationship: none
group_type: group
admin_label: Case
entity_type: oc_case_provision
entity_field: oc_case
plugin_id: standard
required: false
display_description: ''
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user.roles
tags: { }
block_2:
id: block_2
display_title: 'By case'
display_plugin: block
position: 2
display_options:
fields:
oc_provider:
id: oc_provider
table: oc_case_provision_field_data
field: oc_provider
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_provider
plugin_id: field
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
oc_case_provider_role:
id: oc_case_provider_role
table: oc_case_provision_field_data
field: oc_case_provider_role
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case_provider_role
plugin_id: field
label: Role
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
arguments:
oc_case:
id: oc_case
table: oc_case_provision_field_data
field: oc_case
relationship: none
group_type: group
admin_label: ''
entity_type: oc_case_provision
entity_field: oc_case
plugin_id: numeric
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: raw
default_argument_options:
index: 2
use_alias: false
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
override: false
items_per_page: 25
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
defaults:
relationships: false
fields: false
arguments: false
header: false
relationships: { }
display_description: ''
header:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: ''
plugin_id: text_custom
empty: true
content: '<a href=''/opencase/oc_case_provision/add/caseworker?case_id={{ raw_arguments.oc_case }}''>Add a caseworker</a>'
tokenize: true
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user.roles
tags: { }

View File

@ -1,16 +1,6 @@
<?php
use \Drupal\Core\Field\BaseFieldDefinition;
function opencase_cases_update_90005() {
$field_storage_definition = BaseFieldDefinition::create('integer')
->setLabel(t('Number of Cases'))
->setRevisionable(TRUE)
->setDisplayConfigurable('view', true);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('total_cases', 'oc_actor', 'opencase_cases', $field_storage_definition);
}
function opencase_cases_update_90004() {
$field_storage_definition = BaseFieldDefinition::create('string_long')
->setRevisionable(TRUE)

View File

@ -97,23 +97,6 @@ function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFe
$case->addToTotalFee(0 - $case_fee->amount->value);
}
function opencase_cases_oc_case_provision_insert(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
$provider = $case_provision->getProvider()->incrementTotalCases();
}
function opencase_cases_oc_case_provision_delete(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
$provider = $case_provision->getProvider()->decrementTotalCases();
}
function opencase_cases_oc_case_provision_update(Drupal\opencase_cases\entity\OCCaseProvision $case_provision): void {
$new_provider_id = $case_provision->oc_provider->target_id;
$old_provider_id = $case_provision->original->oc_provider->target_id;
if ($new_provider_id != $old_provider_id) {
$case_provision->getProvider()->incrementTotalCases();
$case_provision->original->getProvider()->decrementTotalCases();
}
}
function opencase_cases_entity_base_field_info($entity_type) {
$fields = array();

View File

@ -10,8 +10,6 @@ use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
use Drupal\opencase_entities\Entity\OCActor;
use Error;
/**
* Defines the Case Provision entity.
@ -203,10 +201,6 @@ class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvis
return $this;
}
public function getProvider():?OCActor {
return OCActor::load($this->oc_provider->target_id);
}
/**
* {@inheritdoc}
*/

View File

@ -208,14 +208,13 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface
}
public function incrementTotalCases(): void {
$this->set('total_cases', $this->total_cases->value + 1);
$this->save();
}
public function decrementTotalCases(): void {
$this->set('total_cases', $this->total_cases->value - 1);
$this->save();
public function getCountOfCaseProvisions(array $conditions = []): int {
$query = \Drupal::entityQuery('oc_case_provision');
$query->condition('oc_provider', $this->id());
// foreach($conditions as $condition) {
// $query->condition($condition);
// }
return count($query->execute());
}
/**

38
src/EmailAlerter.php Normal file
View File

@ -0,0 +1,38 @@
<?php declare(strict_types = 1);
namespace Drupal\opencase;
use Drupal\user\Entity\User;
class EmailAlerter {
public function send_email_to_users_with_role(array $params, string $key, string $role): void {
$mailManager = \Drupal::service('plugin.manager.mail');
$module = 'goodnightout_opencase';
$to = implode(',', $this->get_email_addresses_of_users_with_role($role));
$send = true;
$result = $mailManager->mail($module, $key, $to, NULL, $params, NULL, $send);
if ($result['result'] != true) {
$message = t('There was a problem sending your email notification to @email.', array('@email' => $to));
\Drupal::messenger()->addMessage($message, 'error');
\Drupal::logger('mail-log')->error($message);
return;
}
$message = t('An email notification has been sent to @email ', array('@email' => $to));
\Drupal::messenger()->addMessage($message);
\Drupal::logger('mail-log')->notice($message);
}
private function get_email_addresses_of_users_with_role(string $role): array {
$email_addresses = [];
$ids = \Drupal::entityQuery('user')
->condition('status', 1)
->condition('roles', $role)
->execute();
$users = User::loadMultiple($ids);
foreach($users as $user){
$email_addresses[] = $user->getEmail();
}
return $email_addresses;
}
}