Compare commits
	
		
			209 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d8f1f4cbdd | |||
| 22640f02b6 | |||
| 797da77803 | |||
| 66f95f46bf | |||
| b85cbaf398 | |||
| 34b7a1c7c9 | |||
| fb2249d9bd | |||
| 614293c114 | |||
| 167166b898 | |||
| c3f802835f | |||
| 13ddf5aa13 | |||
| 225e92a51c | |||
| 60c64afcab | |||
| 49ab81ca23 | |||
| 65fe65474e | |||
| 57fae7c1c3 | |||
| cc551b0851 | |||
| 40435a16be | |||
| f783fa2373 | |||
| 8b725e5a9a | |||
| 7c3b007ff9 | |||
| f39f4a331d | |||
| 6069ac0901 | |||
| 240a55f54f | |||
| b194367eef | |||
| f293676fa5 | |||
| ba4e6668aa | |||
| 3b62ebd0ee | |||
| 198a3f0558 | |||
| 833c21346d | |||
| 4b84c99541 | |||
| 0de22b7e90 | |||
| dad1ffc746 | |||
| f6c7519a11 | |||
| 27e7e3ae2a | |||
| 5eef57f470 | |||
| d0fea802ee | |||
| 260979edcc | |||
| dbc38e8f61 | |||
| c95f8280bc | |||
| 24a8e8864f | |||
| 90c4462512 | |||
| 52f77cb342 | |||
| 5f790c73c7 | |||
| f617fc207e | |||
| 0c9707419e | |||
| 042e5853bb | |||
| 720b6f005d | |||
| cc2f03ddb3 | |||
| 2411813bd6 | |||
| d4e8991804 | |||
| 658e60f296 | |||
| 2ecef5c1dd | |||
| 92e81ee518 | |||
| d7197d7ed6 | |||
| 3458949bb0 | |||
| 9e18b3ea28 | |||
| 623e801c58 | |||
| f9d4820ac2 | |||
| 88cd511d9f | |||
| 9ee00ed738 | |||
| ff94eb8285 | |||
| cf7892ed15 | |||
| 72e7cb99c3 | |||
| 04d6525d6c | |||
| d9453c1323 | |||
| 3eba291d5a | |||
| de691b5a52 | |||
| 8cde0b8892 | |||
| cffe817ce9 | |||
| 3753b4e25c | |||
| f601890ad0 | |||
| 6dca2e98e9 | |||
| c19b7d4be8 | |||
| b6afcfe47a | |||
| 4b8872b586 | |||
| 8d2d095b8e | |||
| 0c977a7d48 | |||
| a4c02ed249 | |||
| a0e4b4028f | |||
| 5c20e83ed5 | |||
| 78b8371be9 | |||
| 48e6ae4196 | |||
| ac4e6eddd5 | |||
| b1a8534d29 | |||
| 42bf2c8e77 | |||
| 7e4acae864 | |||
| 80f86c62fd | |||
| 794bc0da68 | |||
| 892a7ae35b | |||
| 3586ef5788 | |||
| 436607a305 | |||
| c7d36df842 | |||
| 8cb50d271b | |||
| 3dcd37bb8c | |||
| 8816441f94 | |||
| 73d9d6490a | |||
| d151b1744e | |||
| 26d78a4f7f | |||
| 41505594be | |||
| 3f3945f9a0 | |||
| 1cb3a4356a | |||
| 34ac278a2e | |||
| b7cfaa9f64 | |||
| 0df9cfecc8 | |||
| 27f0b33faa | |||
| 998f72f505 | |||
| 4ac33273b9 | |||
| 99e57d9747 | |||
| 1d257538fe | |||
| 62a3df034e | |||
| df44524498 | |||
| 8d5dda3a7a | |||
| 74fac415c8 | |||
| 20cc8cd753 | |||
| 4647ef6e3e | |||
| 1a7757394e | |||
| fbdc64de3c | |||
| 34a2d9e23b | |||
| bc98ecb541 | |||
| 0f0281c58c | |||
| c65012315d | |||
| 715f5f34c4 | |||
| 403965fe6f | |||
| eec5b876a3 | |||
| 077455b4d3 | |||
| 7a995060ce | |||
| 9646e216aa | |||
| 5afbeb956b | |||
| 2895dcdab8 | |||
| 3dd71bf2c0 | |||
| 6fbaf433e8 | |||
| 4639ff7ffd | |||
| 4285e1952f | |||
| eee7604440 | |||
| 0399c83646 | |||
| 2bc1abc7a7 | |||
| 06937b7443 | |||
| 6d281625b7 | |||
| 208240badc | |||
| c479e3b995 | |||
| 517938ab7b | |||
| b48ba012cb | |||
| 53648faff7 | |||
| a993e09bc6 | |||
| 3aa4fbc5cf | |||
| 0caf2cb7c8 | |||
| e49ad3fc9c | |||
| 146eb2b8ba | |||
| 360fe56a6d | |||
| 91cc94d3d7 | |||
| 2b9cd117ba | |||
| 36eb9d9667 | |||
| d026173c8f | |||
| 7ecdfbf3e6 | |||
| 113ff6361b | |||
| ca1a0eda29 | |||
| dfb12d9be6 | |||
| ea71314345 | |||
| 31be127d30 | |||
| 7c5ee54a44 | |||
| 21528a436e | |||
| ffb99bcac6 | |||
| a7f0e8fb02 | |||
| eb405674dc | |||
| 342459daa3 | |||
| cde0bbc7e6 | |||
| aff262a535 | |||
| 0d927126a2 | |||
| 2f485f19c5 | |||
| 8b07bbe63f | |||
| 690ec3b509 | |||
| 7a9b95bf0d | |||
| 675a85dfb6 | |||
| 17f8ddba2e | |||
| 27cb58512e | |||
| df2c826a33 | |||
| 6f33d59842 | |||
| e37a41de2b | |||
| c47df855bc | |||
| af3b4727f1 | |||
| 011029d3b3 | |||
| 9af1d58de8 | |||
| 6d93242fa9 | |||
| c9a843a35f | |||
| c46bbc6ffd | |||
| 5d1844304a | |||
| be45fd2d42 | |||
| 18a0846348 | |||
| 18e32335f5 | |||
| b83f0b44b4 | |||
| 7f88d409f0 | |||
| 8841fd4d25 | |||
| 87241c1f87 | |||
| 2a1607c6d9 | |||
| d8fd12a7b9 | |||
| e4a04a254d | |||
| 88b5ce3d2e | |||
| ae3976c7b8 | |||
| f47ded38fa | |||
| c63cae6b71 | |||
| a7a96ab03c | |||
| a6db6615df | |||
| 1c3370a784 | |||
| 59f4987371 | |||
| c1e24593fa | |||
| c98f028045 | |||
| 873f751795 | |||
| 6b9ff3a5e7 | 
| @ -1,5 +1,5 @@ | ||||
| # OpenCase | ||||
| A simple case-management system for small altruistic organisations. | ||||
| A simple case-management system | ||||
|  | ||||
| ## The Plan | ||||
| OpenCase will be available as: | ||||
| @ -28,7 +28,7 @@ If you want to install OpenCase for yourself, please get in touch via Issues. It | ||||
| A demo site, with basic functionality is available at demo.opencase.org.uk. If you are interested, raise an issue and I will get the login to you somehow.  | ||||
|  | ||||
| ## Find out more | ||||
| * More details, including user stories for future development, can be found in the [OpenCase Gitbook](https://hoegrammer.gitbooks.io/zen-crm/content/) | ||||
| * More details, including user stories for future development, can be found in the [OpenCase Gitbook](https://hoegrammer.gitbooks.io/opencase/content/) | ||||
| * Raise an issue to contact the developer.  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										5
									
								
								ciac_opencase_customisations.libraries.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								ciac_opencase_customisations.libraries.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| ciac_grouped_views: | ||||
|   version: 1.x | ||||
|   css: | ||||
|     layout: | ||||
|       css/grouped_views.css: {} | ||||
| @ -1,14 +1,17 @@ | ||||
| { | ||||
|   "name": "drupal/opencase", | ||||
|   "type": "drupal-module", | ||||
|   "description": "Simple Case Management", | ||||
|   "keywords": ["Drupal"], | ||||
|   "license": "GPL-2.0+", | ||||
|   "homepage": "https://www.drupal.org/project/opencase", | ||||
|   "minimum-stability": "dev", | ||||
|   "support": { | ||||
|     "issues": "https://www.drupal.org/project/issues/opencase", | ||||
|     "source": "http://cgit.drupalcode.org/opencase" | ||||
|   }, | ||||
|   "require": { } | ||||
|     "name": "autonomic/opencase", | ||||
|     "type": "drupal-module", | ||||
|     "authors": [ | ||||
|         { | ||||
|             "name": "autonomic", | ||||
|             "email": "helo@autonomic.zone" | ||||
|         } | ||||
|     ], | ||||
|     "require": { | ||||
|         "composer/installers": "*", | ||||
|         "drupal/superfish": "*", | ||||
|         "drupal/views_autosubmit": "*", | ||||
|         "drupal/smtp": "*", | ||||
|         "drupal/paragraphs_collapsible": "*" | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,28 @@ | ||||
| langcode: en | ||||
| status: true | ||||
| dependencies: | ||||
|   config: | ||||
|     - views.view.equal_opps_records | ||||
|   module: | ||||
|     - system | ||||
|     - views | ||||
|   theme: | ||||
|     - bartik | ||||
| id: exposedformequal_opps_recordspage_1 | ||||
| theme: bartik | ||||
| region: content | ||||
| weight: 0 | ||||
| provider: null | ||||
| plugin: 'views_exposed_filter_block:equal_opps_records-page_1' | ||||
| settings: | ||||
|   id: 'views_exposed_filter_block:equal_opps_records-page_1' | ||||
|   label: '' | ||||
|   provider: views | ||||
|   label_display: visible | ||||
|   views_label: 'Search by (whole) first or last name.' | ||||
| visibility: | ||||
|   request_path: | ||||
|     id: request_path | ||||
|     pages: /equal-opps-records | ||||
|     negate: false | ||||
|     context_mapping: {  } | ||||
| @ -1,19 +0,0 @@ | ||||
| langcode: en | ||||
| status: true | ||||
| dependencies: | ||||
|   module: | ||||
|     - opencase | ||||
|   theme: | ||||
|     - bartik | ||||
| id: opencasecontextualmenu | ||||
| theme: bartik | ||||
| region: sidebar_second | ||||
| weight: -8 | ||||
| provider: null | ||||
| plugin: opencase_contextual_menu | ||||
| settings: | ||||
|   id: opencase_contextual_menu | ||||
|   label: 'OpenCase Contextual Menu' | ||||
|   provider: opencase | ||||
|   label_display: '0' | ||||
| visibility: {  } | ||||
| @ -0,0 +1,8 @@ | ||||
| uuid: 85aacc47-8df9-4309-b7f4-f58be70f83d0 | ||||
| langcode: en | ||||
| status: true | ||||
| dependencies: {  } | ||||
| name: 'Case Provider Roles' | ||||
| vid: oc_case_provider_role | ||||
| description: '' | ||||
| weight: 0 | ||||
							
								
								
									
										8
									
								
								config/install/taxonomy.vocabulary.oc_fee_category.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								config/install/taxonomy.vocabulary.oc_fee_category.yml
									
									
									
									
									
										Normal 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 | ||||
| @ -1,609 +0,0 @@ | ||||
| langcode: en | ||||
| status: true | ||||
| dependencies: | ||||
|   config: | ||||
|     - user.role.authenticated | ||||
|   module: | ||||
|     - opencase_entities | ||||
|     - user | ||||
| id: cases | ||||
| label: Cases | ||||
| module: views | ||||
| description: '' | ||||
| tag: '' | ||||
| base_table: oc_case_field_data | ||||
| base_field: id | ||||
| core: 8.x | ||||
| display: | ||||
|   default: | ||||
|     display_plugin: default | ||||
|     id: default | ||||
|     display_title: Master | ||||
|     position: 0 | ||||
|     display_options: | ||||
|       access: | ||||
|         type: role | ||||
|         options: | ||||
|           role: | ||||
|             authenticated: authenticated | ||||
|       cache: | ||||
|         type: none | ||||
|         options: {  } | ||||
|       query: | ||||
|         type: views_query | ||||
|         options: | ||||
|           disable_sql_rewrite: false | ||||
|           distinct: false | ||||
|           replica: false | ||||
|           query_comment: '' | ||||
|           query_tags: {  } | ||||
|       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 | ||||
|       pager: | ||||
|         type: mini | ||||
|         options: | ||||
|           items_per_page: 50 | ||||
|           offset: 0 | ||||
|           id: 0 | ||||
|           total_pages: null | ||||
|           tags: | ||||
|             previous: ‹‹ | ||||
|             next: ›› | ||||
|           expose: | ||||
|             items_per_page: false | ||||
|             items_per_page_label: 'Items per page' | ||||
|             items_per_page_options: '5, 10, 25, 50' | ||||
|             items_per_page_options_all: false | ||||
|             items_per_page_options_all_label: '- All -' | ||||
|             offset: false | ||||
|             offset_label: Offset | ||||
|       style: | ||||
|         type: table | ||||
|       row: | ||||
|         type: fields | ||||
|       fields: | ||||
|         id: | ||||
|           id: id | ||||
|           table: oc_case_field_data | ||||
|           field: id | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: ID | ||||
|           exclude: true | ||||
|           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: value | ||||
|           type: number_integer | ||||
|           settings: | ||||
|             thousand_separator: '' | ||||
|             prefix_suffix: true | ||||
|           group_column: value | ||||
|           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 | ||||
|           entity_type: oc_case | ||||
|           entity_field: id | ||||
|           plugin_id: field | ||||
|         name: | ||||
|           id: name | ||||
|           table: oc_case_field_data | ||||
|           field: name | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: 'Case Title' | ||||
|           exclude: false | ||||
|           alter: | ||||
|             alter_text: false | ||||
|             text: '' | ||||
|             make_link: true | ||||
|             path: '' | ||||
|             absolute: false | ||||
|             external: false | ||||
|             replace_spaces: false | ||||
|             path_case: none | ||||
|             trim_whitespace: false | ||||
|             alt: '' | ||||
|             rel: '' | ||||
|             link_class: '' | ||||
|             prefix: '' | ||||
|             suffix: foo | ||||
|             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: value | ||||
|           type: string | ||||
|           settings: | ||||
|             link_to_entity: false | ||||
|           group_column: value | ||||
|           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 | ||||
|           entity_type: null | ||||
|           entity_field: name | ||||
|           plugin_id: field | ||||
|         type: | ||||
|           id: type | ||||
|           table: oc_case_field_data | ||||
|           field: type | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: Type | ||||
|           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: false | ||||
|           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 | ||||
|           entity_type: oc_case | ||||
|           entity_field: type | ||||
|           plugin_id: field | ||||
|         actors_involved_target_id: | ||||
|           id: actors_involved_target_id | ||||
|           table: oc_case__actors_involved | ||||
|           field: actors_involved_target_id | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: 'Involved Parties' | ||||
|           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 | ||||
|           entity_type: oc_case | ||||
|           entity_field: actors_involved | ||||
|           plugin_id: field | ||||
|         created: | ||||
|           id: created | ||||
|           table: oc_case_field_data | ||||
|           field: created | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: Created | ||||
|           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: value | ||||
|           type: timestamp | ||||
|           settings: | ||||
|             date_format: short | ||||
|             custom_date_format: '' | ||||
|             timezone: '' | ||||
|           group_column: value | ||||
|           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 | ||||
|           entity_type: oc_case | ||||
|           entity_field: created | ||||
|           plugin_id: field | ||||
|         nothing: | ||||
|           id: nothing | ||||
|           table: views | ||||
|           field: nothing | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           label: 'Go to' | ||||
|           exclude: false | ||||
|           alter: | ||||
|             alter_text: true | ||||
|             text: "<ul><li><a href='/opencase/oc_case/{{ id }}'>Details/Files</a></li>\n<li><a href='/opencase/oc_case/{{ id}}/activity_list'>Activities</a>\n</li></ul>" | ||||
|             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: false | ||||
|           plugin_id: custom | ||||
|       filters: null | ||||
|       sorts: | ||||
|         created: | ||||
|           id: created | ||||
|           table: oc_case_field_data | ||||
|           field: created | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           order: DESC | ||||
|           exposed: false | ||||
|           expose: | ||||
|             label: '' | ||||
|           granularity: day | ||||
|           entity_type: oc_case | ||||
|           entity_field: created | ||||
|           plugin_id: date | ||||
|       title: '' | ||||
|       header: | ||||
|         area: | ||||
|           id: area | ||||
|           table: views | ||||
|           field: area | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           empty: true | ||||
|           tokenize: false | ||||
|           content: | ||||
|             value: '<p>To <strong>add a new case</strong>, first search for the person you want to add it to. If the person is not on the system yet, you can add them using the "People" menu.</p>' | ||||
|             format: basic_html | ||||
|           plugin_id: text | ||||
|       footer: {  } | ||||
|       empty: | ||||
|         area_text_custom: | ||||
|           id: area_text_custom | ||||
|           table: views | ||||
|           field: area_text_custom | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           empty: true | ||||
|           tokenize: false | ||||
|           content: "<p>Either there are no cases involving this person, or you do not have access to them.</p>\n" | ||||
|           plugin_id: text_custom | ||||
|       relationships: {  } | ||||
|       arguments: | ||||
|         actors_involved_target_id: | ||||
|           id: actors_involved_target_id | ||||
|           table: oc_case__actors_involved | ||||
|           field: actors_involved_target_id | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           default_action: ignore | ||||
|           exception: | ||||
|             value: all | ||||
|             title_enable: false | ||||
|             title: All | ||||
|           title_enable: false | ||||
|           title: '' | ||||
|           default_argument_type: fixed | ||||
|           default_argument_options: | ||||
|             argument: '' | ||||
|           default_argument_skip_url: false | ||||
|           summary_options: | ||||
|             base_path: '' | ||||
|             count: true | ||||
|             items_per_page: 25 | ||||
|             override: false | ||||
|           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 | ||||
|           entity_type: oc_case | ||||
|           entity_field: actors_involved | ||||
|           plugin_id: numeric | ||||
|       display_extenders: {  } | ||||
|       use_ajax: true | ||||
|     cache_metadata: | ||||
|       max-age: -1 | ||||
|       contexts: | ||||
|         - 'languages:language_content' | ||||
|         - 'languages:language_interface' | ||||
|         - url | ||||
|         - url.query_args | ||||
|         - user.roles | ||||
|       tags: {  } | ||||
|   page_1: | ||||
|     display_plugin: page | ||||
|     id: page_1 | ||||
|     display_title: Page | ||||
|     position: 1 | ||||
|     display_options: | ||||
|       display_extenders: {  } | ||||
|       path: opencase/oc_actor/%actor_id/case_list | ||||
|       defaults: | ||||
|         filters: false | ||||
|         filter_groups: false | ||||
|       filters: {  } | ||||
|       filter_groups: | ||||
|         operator: AND | ||||
|         groups: | ||||
|           1: AND | ||||
|     cache_metadata: | ||||
|       max-age: -1 | ||||
|       contexts: | ||||
|         - 'languages:language_content' | ||||
|         - 'languages:language_interface' | ||||
|         - url | ||||
|         - url.query_args | ||||
|         - user.roles | ||||
|       tags: {  } | ||||
|   page_2: | ||||
|     display_plugin: page | ||||
|     id: page_2 | ||||
|     display_title: 'All Cases' | ||||
|     position: 2 | ||||
|     display_options: | ||||
|       display_extenders: {  } | ||||
|       display_description: '' | ||||
|       arguments: {  } | ||||
|       defaults: | ||||
|         arguments: false | ||||
|         filters: false | ||||
|         filter_groups: false | ||||
|         empty: false | ||||
|       path: opencase/all-cases | ||||
|       filters: null | ||||
|       filter_groups: | ||||
|         operator: AND | ||||
|         groups: | ||||
|           1: AND | ||||
|       empty: | ||||
|         area_text_custom: | ||||
|           id: area_text_custom | ||||
|           table: views | ||||
|           field: area_text_custom | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           empty: true | ||||
|           tokenize: false | ||||
|           content: "<h1>No cases found</h1>\n<p>You do not have access to any existing cases.</p>\n<p>To <b>add a new case</b>, first search for the person you want to add a case to. If they are not on the system yet you can add them using the <b>Add actors</b> menu in the left sidebar.</p>\n" | ||||
|           plugin_id: text_custom | ||||
|     cache_metadata: | ||||
|       max-age: -1 | ||||
|       contexts: | ||||
|         - 'languages:language_content' | ||||
|         - 'languages:language_interface' | ||||
|         - url.query_args | ||||
|         - user.roles | ||||
|       tags: {  } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										308
									
								
								config/install/views.view.equal_opps_records.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										308
									
								
								config/install/views.view.equal_opps_records.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,308 @@ | ||||
| langcode: en | ||||
| status: true | ||||
| dependencies: | ||||
|   config: | ||||
|     - system.menu.opencase | ||||
|   module: | ||||
|     - opencase_entities | ||||
|     - user | ||||
|     - views_autosubmit | ||||
| id: equal_opps_records | ||||
| label: 'Equal Opps Records' | ||||
| module: views | ||||
| description: '' | ||||
| tag: '' | ||||
| base_table: oc_equal_opps | ||||
| base_field: id | ||||
| display: | ||||
|   default: | ||||
|     display_plugin: default | ||||
|     id: default | ||||
|     display_title: Master | ||||
|     position: 0 | ||||
|     display_options: | ||||
|       access: | ||||
|         type: perm | ||||
|         options: | ||||
|           perm: 'view published equal opps entities' | ||||
|       cache: | ||||
|         type: tag | ||||
|         options: {  } | ||||
|       query: | ||||
|         type: views_query | ||||
|         options: | ||||
|           disable_sql_rewrite: false | ||||
|           distinct: false | ||||
|           replica: false | ||||
|           query_comment: '' | ||||
|           query_tags: {  } | ||||
|       exposed_form: | ||||
|         type: autosubmit | ||||
|         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 | ||||
|           autosubmit_hide: true | ||||
|       pager: | ||||
|         type: mini | ||||
|         options: | ||||
|           items_per_page: 10 | ||||
|           offset: 0 | ||||
|           id: 0 | ||||
|           total_pages: null | ||||
|           expose: | ||||
|             items_per_page: false | ||||
|             items_per_page_label: 'Items per page' | ||||
|             items_per_page_options: '5, 10, 25, 50' | ||||
|             items_per_page_options_all: false | ||||
|             items_per_page_options_all_label: '- All -' | ||||
|             offset: false | ||||
|             offset_label: Offset | ||||
|           tags: | ||||
|             previous: ‹‹ | ||||
|             next: ›› | ||||
|       style: | ||||
|         type: table | ||||
|       row: | ||||
|         type: fields | ||||
|       fields: | ||||
|         name: | ||||
|           id: name | ||||
|           table: oc_equal_opps | ||||
|           field: name | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           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: value | ||||
|           type: string | ||||
|           settings: | ||||
|             link_to_entity: true | ||||
|           group_column: value | ||||
|           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 | ||||
|           entity_type: null | ||||
|           entity_field: name | ||||
|           plugin_id: field | ||||
|       filters: | ||||
|         status: | ||||
|           value: '1' | ||||
|           table: oc_equal_opps | ||||
|           field: status | ||||
|           plugin_id: boolean | ||||
|           entity_type: oc_equal_opps | ||||
|           entity_field: status | ||||
|           id: status | ||||
|           expose: | ||||
|             operator: '' | ||||
|             operator_limit_selection: false | ||||
|             operator_list: {  } | ||||
|           group: 1 | ||||
|         first_name: | ||||
|           id: first_name | ||||
|           table: oc_actor_field_data | ||||
|           field: first_name | ||||
|           relationship: oc_actor | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           operator: '=' | ||||
|           value: '' | ||||
|           group: 1 | ||||
|           exposed: true | ||||
|           expose: | ||||
|             operator_id: first_name_op | ||||
|             label: 'First Name' | ||||
|             description: '' | ||||
|             use_operator: false | ||||
|             operator: first_name_op | ||||
|             operator_limit_selection: false | ||||
|             operator_list: {  } | ||||
|             identifier: first_name | ||||
|             required: false | ||||
|             remember: false | ||||
|             multiple: false | ||||
|             remember_roles: | ||||
|               authenticated: authenticated | ||||
|               anonymous: '0' | ||||
|               administrator: '0' | ||||
|               gno_standard_user: '0' | ||||
|             placeholder: '' | ||||
|           is_grouped: false | ||||
|           group_info: | ||||
|             label: '' | ||||
|             description: '' | ||||
|             identifier: '' | ||||
|             optional: true | ||||
|             widget: select | ||||
|             multiple: false | ||||
|             remember: false | ||||
|             default_group: All | ||||
|             default_group_multiple: {  } | ||||
|             group_items: {  } | ||||
|           entity_type: oc_actor | ||||
|           entity_field: first_name | ||||
|           plugin_id: string | ||||
|         last_name: | ||||
|           id: last_name | ||||
|           table: oc_actor_field_data | ||||
|           field: last_name | ||||
|           relationship: oc_actor | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           operator: '=' | ||||
|           value: '' | ||||
|           group: 1 | ||||
|           exposed: true | ||||
|           expose: | ||||
|             operator_id: last_name_op | ||||
|             label: 'Last Name' | ||||
|             description: '' | ||||
|             use_operator: false | ||||
|             operator: last_name_op | ||||
|             operator_limit_selection: false | ||||
|             operator_list: {  } | ||||
|             identifier: last_name | ||||
|             required: false | ||||
|             remember: false | ||||
|             multiple: false | ||||
|             remember_roles: | ||||
|               authenticated: authenticated | ||||
|               anonymous: '0' | ||||
|               administrator: '0' | ||||
|               gno_standard_user: '0' | ||||
|             placeholder: '' | ||||
|           is_grouped: false | ||||
|           group_info: | ||||
|             label: '' | ||||
|             description: '' | ||||
|             identifier: '' | ||||
|             optional: true | ||||
|             widget: select | ||||
|             multiple: false | ||||
|             remember: false | ||||
|             default_group: All | ||||
|             default_group_multiple: {  } | ||||
|             group_items: {  } | ||||
|           entity_type: oc_actor | ||||
|           entity_field: last_name | ||||
|           plugin_id: string | ||||
|       sorts: {  } | ||||
|       title: 'Equal Opps Records' | ||||
|       header: {  } | ||||
|       footer: {  } | ||||
|       empty: | ||||
|         area: | ||||
|           id: area | ||||
|           table: views | ||||
|           field: area | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: '' | ||||
|           empty: true | ||||
|           tokenize: false | ||||
|           content: | ||||
|             value: 'There is no Equal Opps record by that name. Please check the spelling' | ||||
|             format: basic_html | ||||
|           plugin_id: text | ||||
|       relationships: | ||||
|         oc_actor: | ||||
|           id: oc_actor | ||||
|           table: oc_equal_opps | ||||
|           field: oc_actor | ||||
|           relationship: none | ||||
|           group_type: group | ||||
|           admin_label: Person | ||||
|           required: true | ||||
|           entity_type: oc_equal_opps | ||||
|           entity_field: oc_actor | ||||
|           plugin_id: standard | ||||
|       arguments: {  } | ||||
|       display_extenders: {  } | ||||
|       use_ajax: true | ||||
|     cache_metadata: | ||||
|       max-age: -1 | ||||
|       contexts: | ||||
|         - 'languages:language_content' | ||||
|         - 'languages:language_interface' | ||||
|         - url | ||||
|         - url.query_args | ||||
|         - user.permissions | ||||
|       tags: {  } | ||||
|   page_1: | ||||
|     display_plugin: page | ||||
|     id: page_1 | ||||
|     display_title: Page | ||||
|     position: 1 | ||||
|     display_options: | ||||
|       display_extenders: {  } | ||||
|       path: equal-opps-records | ||||
|       exposed_block: true | ||||
|       menu: | ||||
|         type: normal | ||||
|         title: 'Equal Opps Records' | ||||
|         description: '' | ||||
|         expanded: false | ||||
|         parent: opencase.see_all | ||||
|         weight: 10 | ||||
|         context: '0' | ||||
|         menu_name: opencase | ||||
|     cache_metadata: | ||||
|       max-age: -1 | ||||
|       contexts: | ||||
|         - 'languages:language_content' | ||||
|         - 'languages:language_interface' | ||||
|         - url | ||||
|         - url.query_args | ||||
|         - user.permissions | ||||
|       tags: {  } | ||||
							
								
								
									
										12
									
								
								config/schema/oc_event.schema.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								config/schema/oc_event.schema.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| opencase.oc_event.*: | ||||
|   type: config_entity | ||||
|   label: 'Event config' | ||||
|   mapping: | ||||
|     id: | ||||
|       type: string | ||||
|       label: 'ID' | ||||
|     label: | ||||
|       type: label | ||||
|       label: 'Label' | ||||
|     uuid: | ||||
|       type: string | ||||
							
								
								
									
										171
									
								
								css/opencase.css
									
									
									
									
									
								
							
							
						
						
									
										171
									
								
								css/opencase.css
									
									
									
									
									
								
							| @ -1,9 +1,85 @@ | ||||
| /* MOVE THIS INTO MORE!! */ | ||||
| .top_ups_bought.add-activity-link { | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
| /* paragraphs */ | ||||
|  | ||||
|  | ||||
| .paragraph .field { | ||||
|     width: auto; | ||||
| } | ||||
|  | ||||
| .field.field--type-entity-reference-revisions { | ||||
|     border: none; | ||||
|     padding: 0.4em; | ||||
| } | ||||
|  | ||||
| .field.field--type-entity-reference-revisions .field__item { | ||||
|     padding: 0; | ||||
| } | ||||
|  | ||||
| /* end paragraphs */ | ||||
|  | ||||
|  | ||||
| /* MOVE THIS INTO GNO! */ | ||||
| #block-accreditationcount { | ||||
|   position: absolute; | ||||
|   right: 50%; | ||||
|   /*background-color: #fff;*/ | ||||
|   background-image: linear-gradient(to top, #2a419a 0%, #1d84c3 100%); | ||||
|   border-radius: 5px; | ||||
| } | ||||
|  | ||||
| #block-accreditationcount table { | ||||
|   border: 0px #2a419a; | ||||
|   background-color: #1d84c3; | ||||
| } | ||||
|  | ||||
| #block-accreditationcount h1 { | ||||
|   color: white; | ||||
| } | ||||
|  | ||||
|  | ||||
| #block-accreditationcount td { | ||||
|   color: black; | ||||
| } | ||||
|  | ||||
| /*  */ | ||||
|  | ||||
| body { | ||||
|   font-size: 100% !important; | ||||
| } | ||||
|  | ||||
| .field.field--type-entity-reference { | ||||
|   margin: inherit; | ||||
| } | ||||
|  | ||||
| .field { | ||||
|     width: 30%; | ||||
|     display: inline-block; | ||||
|     padding: 0.4em; | ||||
| } | ||||
|  | ||||
| /* remove this confusing thing from user creation page */ | ||||
| #edit-password-policy-status { | ||||
|   display: none; | ||||
| }  | ||||
|  | ||||
| .form-composite > .fieldset-wrapper > .description, .form-item .description { | ||||
|     font-size: 1em !important; | ||||
| } | ||||
|  | ||||
| div[data-drupal-selector=edit-user-bulk-form] { | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
| .layout-container { | ||||
|     max-width: 95% !important; | ||||
| } | ||||
|  | ||||
| /* Free the people from the tyranny of the useless search button */ | ||||
| #edit-submit-actor-search{ | ||||
| #edit-submit-actor-search, #edit-submit-actor-search--2{ | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
| @ -41,3 +117,96 @@ body { | ||||
| .block-superfish .menu ul li a:hover { | ||||
|   color: black; | ||||
| } | ||||
|  | ||||
| /* In views, display label at top of field. Ths is because full descriptions are displayed in the activity view so having the label in the middle means it disappears down the page. */ | ||||
| td.views-field { | ||||
|     vertical-align: top; | ||||
| } | ||||
|  | ||||
| /* Entity displays */ | ||||
| .oc_entity .left { | ||||
|   display: inline-block; | ||||
|   width: 45%; | ||||
|   padding: 1em; | ||||
| } | ||||
|  | ||||
| .oc_entity .right { | ||||
|   display: inline-block; | ||||
|   width: 45%; | ||||
|   padding: 1em; | ||||
|   float: right; | ||||
| } | ||||
| .oc_entity .field { | ||||
|   margin-top: 1em; | ||||
| } | ||||
|  | ||||
| /* Make entity reference field labels match normal field labels */ | ||||
| .field--type-entity-reference .field__label { | ||||
|   font-family: Georgia, "Times New Roman", Times, serif; | ||||
|   font-size: 1em !important; | ||||
|   font-weight: bold !important; | ||||
| } | ||||
|  | ||||
| /* remove "details" accordion, see https://drupal.stackexchange.com/questions/294312/why-has-this-details-accordion-appeared-in-this-view */ | ||||
| .views-table details { | ||||
|     display: none; | ||||
| } | ||||
|  | ||||
| form.oc-organisation-relation-form tr:first-child { | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
|  | ||||
| /* trav styling */ | ||||
| .site-branding { | ||||
| 	margin-top: -2.20em !important; | ||||
| } | ||||
|  | ||||
| .follow-ups-due td { | ||||
|   background-color: #FB8A4F; | ||||
| } | ||||
|  | ||||
| #block-accreditationcount th, | ||||
| #block-accreditationcount td { | ||||
|   border: none; | ||||
| } | ||||
|  | ||||
| #block-accreditationcount { | ||||
|   padding: 1em; | ||||
| } | ||||
|  | ||||
| tr:nth-child(even) { | ||||
|   background-color: #fefefe; | ||||
| } | ||||
|  | ||||
| tr:nth-child(odd) { | ||||
|   background-color: #eee; | ||||
| } | ||||
|  | ||||
| .Off { | ||||
| 	color:gray; | ||||
| } | ||||
|  | ||||
| .Off a { | ||||
| 	color:gray; | ||||
| } | ||||
|  | ||||
| .field--type-entity-reference-revisions { | ||||
| 	border-radius: 25px; | ||||
| 	border: 2px solid #2A419A; | ||||
| 	padding: 10px;  | ||||
| 	border-width: thin; | ||||
| } | ||||
|  | ||||
| .follow-ups-due table{ | ||||
| 	background-color: #FB8A4F; | ||||
| } | ||||
|  | ||||
| .views-field-field-client-substatus { | ||||
| 	font-weight: bold; | ||||
| }	 | ||||
|  | ||||
| thead { | ||||
| 	background-color: #1d84c3; | ||||
| }	 | ||||
|  | ||||
|  | ||||
							
								
								
									
										67
									
								
								docs/install.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								docs/install.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | ||||
|  | ||||
| composer create-project drupal/recommended-project:8.9.8 drupal | ||||
|  | ||||
| # ADD THIS TO drupal/composer.json IN THE REPOSITORIES SECTION | ||||
| ,{ | ||||
|  | ||||
|             "type": "vcs", | ||||
|             "url": "https://git.autonomic.zone/autonomic-cooperative/opencase.git" | ||||
|         } | ||||
|  | ||||
|  | ||||
| # INSTALL MODULES VIA COMPOSER (this will add them to composer.json, which is better than using a premade one, because this way the versions will all sort themselves out) | ||||
| composer require drupal/admin_toolbar drupal/security_review drupal/smtp drupal/opencase drupal/superfish | ||||
|  | ||||
| # CREATE DIRECTORIES AND SET UP FILE PERMISSIONS | ||||
|  | ||||
| # start in drupal directory | ||||
| mkdir -p config/sync | ||||
| mkdir private | ||||
|  | ||||
| # if web server user =/= deployment user: | ||||
| # start in drupal directory | ||||
|     sudo chgrp www-data config/sync | ||||
|     cd web | ||||
|     cp sites/default/default.settings.php sites/default/settings.php | ||||
|     sudo chgrp www-data . -R | ||||
|     mkdir sites/default/files | ||||
|     sudo chmod g+w sites/default/files -R | ||||
|     chmod g+w sites/default/settings.php | ||||
|     sudo find -type d -exec chmod g+s {} \; | ||||
|     sudo chmod g-w sites/default/ | ||||
|     sudo chmod g-w sites | ||||
|     sudo chmod g-w sites ./sites/example.settings.local.php ./sites/development.services.yml ./sites/example.sites.php ./sites/default/default.services.yml ./sites/default/default.settings.php ./autoload.php  | ||||
|     sudo chmod g-w -R modules/ | ||||
|     sudo chmod g-w -R core | ||||
|     sudo chmod g-w profiles index.php update.php  | ||||
|     sudo chmod g-w themes -R | ||||
|     sudo chmod g-w web.config robots.txt  | ||||
|     cd ../ | ||||
|     sudo chmod g-w -R web/modules | ||||
|     sudo chgrp www-data private | ||||
|     sudo chmod g+w,o-r,o-x private | ||||
|  | ||||
|  | ||||
| # INSTALL THE SITE | ||||
|  | ||||
| - Create a database  | ||||
| - Go to the url and run the installer | ||||
|  | ||||
| # make settings file unwriteable now that it has been generated | ||||
| sudo chmod a-w sites/default/settings.php | ||||
|  | ||||
| # ENABLE all the above modules  | ||||
| drush en admin_toolbar security_review smtp opencase -y | ||||
|  | ||||
|      | ||||
| # TODO set $trusted_host_patterns (in settings.php) | ||||
| # TODO private files (in settings.php) | ||||
| # TODO Set all the HTML roles to admin only - /admin/config/content/formats | ||||
| # TODO run security review (make eveything untrusted except CRM Admin and Admin) - /admin/config/security-review | ||||
| # TODO homepage -> /opencase/whatever-the-chosen-homepage, 403 - /user/login - /admin/config/system/site-information | ||||
| # TODO disable blocks: tools, main navigation, footer menu - /admin/structure/block | ||||
| # TODO logo & colours - admin/appearance/settings/bartik | ||||
| # TODO disallow registering an account & turn off personal contact forms - /admin/config/people/accounts  | ||||
| # TODO add linked actor field to form display and display display - top of both | ||||
| # TODO change which contact form is the default - /admin/structure/contact | ||||
| # TODO change "short" date formate to d/m/Y - /admin/config/regional/date-time | ||||
| @ -0,0 +1,12 @@ | ||||
| opencase_cases.oc_case_fee_type.*: | ||||
|   type: config_entity | ||||
|   label: 'Case Fee type config' | ||||
|   mapping: | ||||
|     id: | ||||
|       type: string | ||||
|       label: 'ID' | ||||
|     label: | ||||
|       type: label | ||||
|       label: 'Label' | ||||
|     uuid: | ||||
|       type: string | ||||
| @ -0,0 +1,12 @@ | ||||
| opencase_cases.oc_case_provision_type.*: | ||||
|   type: config_entity | ||||
|   label: 'Case Provision type config' | ||||
|   mapping: | ||||
|     id: | ||||
|       type: string | ||||
|       label: 'ID' | ||||
|     label: | ||||
|       type: label | ||||
|       label: 'Label' | ||||
|     uuid: | ||||
|       type: string | ||||
| @ -1,4 +1,4 @@ | ||||
| opencase_entities.oc_case_type.*: | ||||
| opencase_cases.oc_case_type.*: | ||||
|   type: config_entity | ||||
|   label: 'Case type config' | ||||
|   mapping: | ||||
							
								
								
									
										37
									
								
								modules/opencase_cases/oc_case.page.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								modules/opencase_cases/oc_case.page.inc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| <?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['base_fields'] = array(); | ||||
|   $variables['other_fields'] = array(); | ||||
|   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 { | ||||
|       $variables['other_fields'][$key] = $variables['elements'][$key]; | ||||
|       unset($variables['other_fields']['name']); | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										30
									
								
								modules/opencase_cases/oc_case_fee.page.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								modules/opencase_cases/oc_case_fee.page.inc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @file | ||||
|  * Contains oc_case_fee.page.inc. | ||||
|  * | ||||
|  * Page callback for Case Fee entities. | ||||
|  */ | ||||
|  | ||||
| use Drupal\Core\Render\Element; | ||||
|  | ||||
| /** | ||||
|  * Prepares variables for Case Fee templates. | ||||
|  * | ||||
|  * Default template: oc_case_fee.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_fee(array &$variables) { | ||||
|   // Fetch OCCaseFee Entity Object. | ||||
|   $oc_case_fee = $variables['elements']['#oc_case_fee']; | ||||
|  | ||||
|   // Helpful $content variable for templates. | ||||
|   foreach (Element::children($variables['elements']) as $key) { | ||||
|     $variables['content'][$key] = $variables['elements'][$key]; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										30
									
								
								modules/opencase_cases/oc_case_provision.page.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								modules/opencase_cases/oc_case_provision.page.inc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @file | ||||
|  * Contains oc_case_provision.page.inc. | ||||
|  * | ||||
|  * Page callback for Case Provision entities. | ||||
|  */ | ||||
|  | ||||
| use Drupal\Core\Render\Element; | ||||
|  | ||||
| /** | ||||
|  * Prepares variables for Case Provision templates. | ||||
|  * | ||||
|  * Default template: oc_case_provision.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_provision(array &$variables) { | ||||
|   // Fetch OCCaseProvision Entity Object. | ||||
|   $oc_case_provision = $variables['elements']['#oc_case_provision']; | ||||
|  | ||||
|   // Helpful $content variable for templates. | ||||
|   foreach (Element::children($variables['elements']) as $key) { | ||||
|     $variables['content'][$key] = $variables['elements'][$key]; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										11
									
								
								modules/opencase_cases/opencase_cases.info.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								modules/opencase_cases/opencase_cases.info.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| name: 'Opencase Cases' | ||||
| type: module | ||||
| description: 'Provides case entities and a required field on activities linking them to a case.' | ||||
| core_version_requirement: 9.x | ||||
| package: OpenCase | ||||
| dependencies: | ||||
|   0: opencase_entities | ||||
|   1: datetime | ||||
|   4: options | ||||
|   5: paragraphs | ||||
|   6: user | ||||
							
								
								
									
										102
									
								
								modules/opencase_cases/opencase_cases.install
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								modules/opencase_cases/opencase_cases.install
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,102 @@ | ||||
| <?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. | ||||
|   if(!db_table_exists('oc_case_provision')) { | ||||
|     \Drupal::entityTypeManager()->clearCachedDefinitions(); | ||||
|     \Drupal::entityDefinitionUpdateManager() | ||||
|       ->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_case_provision')); | ||||
|   } | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_8026() { | ||||
|     $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']]) | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(FALSE); | ||||
|   \Drupal::entityDefinitionUpdateManager() | ||||
|     ->installFieldStorageDefinition('oc_case_provider_role', 'oc_case_provision', 'oc_case_provision', $storage_definition); | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_8027() { | ||||
|   //check if the table exists first.  If not, then create the entity. | ||||
|   if(!db_table_exists('oc_case_fee')) { | ||||
|     \Drupal::entityTypeManager()->clearCachedDefinitions(); | ||||
|     \Drupal::entityDefinitionUpdateManager() | ||||
|       ->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_case_fee')); | ||||
|   } | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_8028() { | ||||
|     $storage_definition =  \Drupal\Core\Field\BaseFieldDefinition::create('decimal') | ||||
|       ->setLabel(t('Amount')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSettings([ | ||||
|         'prefix' => '£', | ||||
|       ]) | ||||
|       ->SetDisplayConfigurable("form", true) | ||||
|       ->SetDisplayConfigurable("view", true); | ||||
|   \Drupal::entityDefinitionUpdateManager() | ||||
|     ->installFieldStorageDefinition('amount', 'oc_case_fee', 'oc_case_fee', $storage_definition); | ||||
|     $storage_definition =  \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Fee Category')) | ||||
|       ->setSetting('target_type', 'taxonomy_term') | ||||
|       ->setSetting('handler_settings', ['target_bundles' => ['oc_fee_category' => 'oc_fee_category']]) | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(FALSE); | ||||
|   \Drupal::entityDefinitionUpdateManager() | ||||
|     ->installFieldStorageDefinition('oc_fee_category', 'oc_case_fee', 'oc_case_fee', $storage_definition); | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_8029() { | ||||
|     $storage_definition =  \Drupal\Core\Field\BaseFieldDefinition::create('string_long') | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setLabel(t('Notes')) | ||||
|       ->setSettings(array( | ||||
|         'default_value' => '', | ||||
|         'max_length' => 255, | ||||
|         'text_processing' => 0, | ||||
|       )) | ||||
|       ->setDisplayConfigurable('form', true) | ||||
|       ->setDisplayConfigurable('view', true); | ||||
|   \Drupal::entityDefinitionUpdateManager() | ||||
|     ->installFieldStorageDefinition('notes', 'oc_case', 'oc_case', $storage_definition); | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_8030() { | ||||
|     $storage_definition =  \Drupal\Core\Field\BaseFieldDefinition::create('decimal') | ||||
|     ->setLabel(t('Total Fee')) | ||||
|     ->setRevisionable(TRUE) | ||||
|     ->setSettings([ | ||||
|       'prefix' => '£', | ||||
|     ]) | ||||
|     ->SetDisplayConfigurable("view", true); | ||||
|   \Drupal::entityDefinitionUpdateManager() | ||||
|     ->installFieldStorageDefinition('total_fee', 'oc_case', 'oc_case', $storage_definition); | ||||
| } | ||||
							
								
								
									
										32
									
								
								modules/opencase_cases/opencase_cases.links.action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								modules/opencase_cases/opencase_cases.links.action.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
|  | ||||
| entity.oc_case.add_form: | ||||
|   route_name: entity.oc_case.add_page | ||||
|   title: 'Add Case' | ||||
|   appears_on: | ||||
|     - entity.oc_case.collection | ||||
| entity.oc_case_type.add_form: | ||||
|   route_name: entity.oc_case_type.add_form | ||||
|   title: 'Add Case type' | ||||
|   appears_on: | ||||
|     - entity.oc_case_type.collection | ||||
|  | ||||
| entity.oc_case_provision.add_form: | ||||
|   route_name: entity.oc_case_provision.add_page | ||||
|   title: 'Add Case Provision' | ||||
|   appears_on: | ||||
|     - entity.oc_case_provision.collection | ||||
| entity.oc_case_provision_type.add_form: | ||||
|   route_name: entity.oc_case_provision_type.add_form | ||||
|   title: 'Add Case Provision type' | ||||
|   appears_on: | ||||
|     - entity.oc_case_provision_type.collection | ||||
| entity.oc_case_fee.add_form: | ||||
|   route_name: entity.oc_case_fee.add_page | ||||
|   title: 'Add Case Fee' | ||||
|   appears_on: | ||||
|     - entity.oc_case_fee.collection | ||||
| entity.oc_case_fee_type.add_form: | ||||
|   route_name: entity.oc_case_fee_type.add_form | ||||
|   title: 'Add Case Fee type' | ||||
|   appears_on: | ||||
|     - entity.oc_case_fee_type.collection | ||||
							
								
								
									
										59
									
								
								modules/opencase_cases/opencase_cases.links.menu.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								modules/opencase_cases/opencase_cases.links.menu.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | ||||
| opencase_cases.manage_case_types: | ||||
|   title: 'Manage case types' | ||||
|   description: 'Configure types of cases and their fields' | ||||
|   menu_name: opencase | ||||
|   parent: opencase.opencase_admin_menu  | ||||
|   url: internal:/admin/opencase/oc_case_type | ||||
|   weight: 2 | ||||
| # Case menu items definition | ||||
| entity.oc_case.collection: | ||||
|   title: 'Case list' | ||||
|   route_name: entity.oc_case.collection | ||||
|   description: 'List Case entities' | ||||
|   parent: system.admin_structure | ||||
|   weight: 100 | ||||
|  | ||||
|  | ||||
| # Case type menu items definition | ||||
| entity.oc_case_type.collection: | ||||
|   title: 'Case type' | ||||
|   route_name: entity.oc_case_type.collection | ||||
|   description: 'List Case type (bundles)' | ||||
|   parent: system.admin_structure | ||||
|   weight: 99 | ||||
|  | ||||
|  | ||||
|  | ||||
| # Case Provision menu items definition | ||||
| entity.oc_case_provision.collection: | ||||
|   title: 'Case Provision list' | ||||
|   route_name: entity.oc_case_provision.collection | ||||
|   description: 'List Case Provision entities' | ||||
|   parent: system.admin_structure | ||||
|   weight: 100 | ||||
|  | ||||
|  | ||||
| # Case Provision type menu items definition | ||||
| entity.oc_case_provision_type.collection: | ||||
|   title: 'Case Provision type' | ||||
|   route_name: entity.oc_case_provision_type.collection | ||||
|   description: 'List Case Provision type (bundles)' | ||||
|   parent: system.admin_structure | ||||
|   weight: 99 | ||||
|  | ||||
| # Case Fee menu items definition | ||||
| entity.oc_case_fee.collection: | ||||
|   title: 'Case Fee list' | ||||
|   route_name: entity.oc_case_fee.collection | ||||
|   description: 'List Case Fee entities' | ||||
|   parent: system.admin_structure | ||||
|   weight: 100 | ||||
|  | ||||
|  | ||||
| # Case Fee type menu items definition | ||||
| entity.oc_case_fee_type.collection: | ||||
|   title: 'Case Fee type' | ||||
|   route_name: entity.oc_case_fee_type.collection | ||||
|   description: 'List Case Fee type (bundles)' | ||||
|   parent: system.admin_structure | ||||
|   weight: 99 | ||||
							
								
								
									
										67
									
								
								modules/opencase_cases/opencase_cases.links.task.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								modules/opencase_cases/opencase_cases.links.task.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | ||||
|  | ||||
| # Case routing definition | ||||
|  | ||||
| entity.oc_case.canonical: | ||||
|   route_name: entity.oc_case.canonical | ||||
|   base_route: entity.oc_case.canonical | ||||
|   title: 'View' | ||||
|  | ||||
| entity.oc_case.edit_form: | ||||
|   route_name: entity.oc_case.edit_form | ||||
|   base_route: entity.oc_case.canonical | ||||
|   title: 'Edit' | ||||
|  | ||||
| entity.oc_case.version_history: | ||||
|   route_name: entity.oc_case.version_history | ||||
|   base_route: entity.oc_case.canonical | ||||
|   title: 'Revisions' | ||||
|  | ||||
| entity.oc_case.delete_form: | ||||
|   route_name:  entity.oc_case.delete_form | ||||
|   base_route:  entity.oc_case.canonical | ||||
|   title: Delete | ||||
|   weight: 10 | ||||
| # Case Provision routing definition | ||||
|  | ||||
| entity.oc_case_provision.canonical: | ||||
|   route_name: entity.oc_case_provision.canonical | ||||
|   base_route: entity.oc_case_provision.canonical | ||||
|   title: 'View' | ||||
|  | ||||
| entity.oc_case_provision.edit_form: | ||||
|   route_name: entity.oc_case_provision.edit_form | ||||
|   base_route: entity.oc_case_provision.canonical | ||||
|   title: 'Edit' | ||||
|  | ||||
| entity.oc_case_provision.version_history: | ||||
|   route_name: entity.oc_case_provision.version_history | ||||
|   base_route: entity.oc_case_provision.canonical | ||||
|   title: 'Revisions' | ||||
|  | ||||
| entity.oc_case_provision.delete_form: | ||||
|   route_name:  entity.oc_case_provision.delete_form | ||||
|   base_route:  entity.oc_case_provision.canonical | ||||
|   title: Delete | ||||
|   weight: 10 | ||||
| # Case Fee routing definition | ||||
|  | ||||
| entity.oc_case_fee.canonical: | ||||
|   route_name: entity.oc_case_fee.canonical | ||||
|   base_route: entity.oc_case_fee.canonical | ||||
|   title: 'View' | ||||
|  | ||||
| entity.oc_case_fee.edit_form: | ||||
|   route_name: entity.oc_case_fee.edit_form | ||||
|   base_route: entity.oc_case_fee.canonical | ||||
|   title: 'Edit' | ||||
|  | ||||
| entity.oc_case_fee.version_history: | ||||
|   route_name: entity.oc_case_fee.version_history | ||||
|   base_route: entity.oc_case_fee.canonical | ||||
|   title: 'Revisions' | ||||
|  | ||||
| entity.oc_case_fee.delete_form: | ||||
|   route_name:  entity.oc_case_fee.delete_form | ||||
|   base_route:  entity.oc_case_fee.canonical | ||||
|   title: Delete | ||||
|   weight: 10 | ||||
							
								
								
									
										244
									
								
								modules/opencase_cases/opencase_cases.module
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										244
									
								
								modules/opencase_cases/opencase_cases.module
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,244 @@ | ||||
| <?php | ||||
| declare(strict_types = 1); | ||||
|  | ||||
| /** | ||||
|  * @file | ||||
|  * Contains opencase_cases.module. | ||||
|  */ | ||||
|  | ||||
| use Drupal\Core\Routing\RouteMatchInterface; | ||||
| use PHPUnit\Framework\Constraint\IsEmpty; | ||||
|  | ||||
| use function PHPUnit\Framework\isEmpty; | ||||
|  | ||||
| /** | ||||
|  * Implements hook_help(). | ||||
|  */ | ||||
| function opencase_cases_help($route_name, RouteMatchInterface $route_match) { | ||||
|   switch ($route_name) { | ||||
|     // Main module help for the opencase_cases module. | ||||
|     case 'help.page.opencase_cases': | ||||
|       $output = ''; | ||||
|       $output .= '<h3>' . t('About') . '</h3>'; | ||||
|       $output .= '<p>' . t('Provides case entities and a required field on activities linking them to a case, plus case fee and case provision entities.') . '</p>'; | ||||
|       return $output; | ||||
|  | ||||
|     default: | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements hook_theme(). | ||||
|  */ | ||||
| function opencase_cases_theme() { | ||||
|   return [ | ||||
|     'opencase_cases' => [ | ||||
|       'render element' => 'children', | ||||
|     ], | ||||
|     'oc_case' => [ | ||||
|       'render element' => 'elements', | ||||
|       'file' => 'oc_case.page.inc', | ||||
|       'template' => 'oc_case', | ||||
|     ], | ||||
|     'oc_case_content_add_list' => [ | ||||
|       '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', | ||||
|     ], | ||||
|     'oc_case_provision_content_add_list' => [ | ||||
|       'render element' => 'content', | ||||
|       'variables' => ['content' => NULL], | ||||
|       'file' => 'oc_case_provision.page.inc', | ||||
|     ], | ||||
|     'oc_case_fee' => [ | ||||
|       'render element' => 'elements', | ||||
|       'file' => 'oc_case_fee.page.inc', | ||||
|       'template' => 'oc_case_fee', | ||||
|     ], | ||||
|     'oc_case_fee_content_add_list' => [ | ||||
|       'render element' => 'content', | ||||
|       'variables' => ['content' => NULL], | ||||
|       'file' => 'oc_case_fee.page.inc', | ||||
|     ], | ||||
|   ]; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @return Drupal\opencase_cases\entity\OCCaseFee[] | ||||
|  */ | ||||
| function opencase_cases_get_case_fees(Drupal\opencase_cases\entity\OCCase $case): array { | ||||
|   $query = \Drupal::entityQuery('oc_case_fee') | ||||
|     ->condition('oc_case.target_id', $case->id()); | ||||
|   $case_fee_ids =  $query->execute(); | ||||
|   $case_fees = []; | ||||
|   foreach($case_fee_ids as $id) { | ||||
|     $case_fees[] = Drupal\opencase_cases\entity\OCCaseFee::load($id); | ||||
|   } | ||||
|   return $case_fees; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @return Drupal\opencase_cases\entity\OCActivity[] | ||||
|  */ | ||||
| function opencase_cases_get_activities(Drupal\opencase_cases\entity\OCCase $case): array { | ||||
|   $query = \Drupal::entityQuery('oc_activity') | ||||
|     ->condition('oc_case.target_id', $case->id()); | ||||
|   $activity_ids =  $query->execute(); | ||||
|   $activities = []; | ||||
|   foreach($activity_ids as $id) { | ||||
|     $activities[] = Drupal\opencase_entities\Entity\OCActivity::load($id); | ||||
|   } | ||||
|   return $activities; | ||||
| } | ||||
|  | ||||
| function opencase_cases_get_amount(Drupal\opencase_cases\entity\OCCaseFee $case_fee): string { | ||||
|   if (!isEmpty($case_fee->amount)) return $case_fee->amount->first()->value; | ||||
|   else return '0'; | ||||
| } | ||||
|  | ||||
| function opencase_cases_get_case(Drupal\opencase_cases\entity\OCCaseFee $case_fee): Drupal\opencase_cases\entity\OCCase { | ||||
|   return $case_fee->oc_case->referencedEntities()[0]; | ||||
| } | ||||
|  | ||||
| function opencase_cases_update_total_fee_for_case_belonging_to_case_fee(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void { | ||||
|   $total = 0; | ||||
|   $case = opencase_cases_get_case($case_fee); | ||||
|   $case_fees = opencase_cases_get_case_fees($case); | ||||
|   foreach($case_fees as $case_fee) { | ||||
|     $total += opencase_cases_get_amount($case_fee); | ||||
|   } | ||||
|   $case->set('total_fee', $total);   | ||||
|   $case->save(); | ||||
| } | ||||
|  | ||||
| function opencase_cases_oc_case_fee_update(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void { | ||||
|   opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee); | ||||
| } | ||||
|  | ||||
| function opencase_cases_oc_case_fee_insert(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void { | ||||
|   opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee); | ||||
| } | ||||
|  | ||||
| function opencase_cases_oc_case_fee_delete(Drupal\opencase_cases\entity\OCCaseFee $case_fee): void { | ||||
|   opencase_cases_update_total_fee_for_case_belonging_to_case_fee($case_fee); | ||||
| } | ||||
|  | ||||
| function opencase_cases_entity_base_field_info($entity_type) { | ||||
|   $fields = array(); | ||||
|    | ||||
|   // Add Case field to Activity  | ||||
|   if ($entity_type->id() === 'oc_activity') { | ||||
|     $fields['oc_case'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Case')) | ||||
|       ->setDescription(t('The case this activity belongs to.')) | ||||
|       ->setSetting('target_type', 'oc_case') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDefaultValueCallback('opencase_cases_default_case_id') | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'type' => 'string', | ||||
|         'weight' => -3, | ||||
|       ]) | ||||
|       ->setRequired(TRUE); | ||||
|   } | ||||
|   return $fields; | ||||
| } | ||||
|  | ||||
| // When deleting a case, delete the activities associated with it | ||||
| function opencase_cases_oc_case_delete(Drupal\opencase_cases\Entity\OCCase $case): void { | ||||
|   $activities = opencase_cases_get_activities($case); | ||||
|   foreach ($activities as $activity) { | ||||
|     $activity->delete(); | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * When creating an activity, it sets the case id from the URL. | ||||
|  */ | ||||
| function opencase_cases_default_case_id() { | ||||
|   return array(\Drupal::request()->query->get('case_id')); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implementation of hook_form_alter() | ||||
|  * Changes what page is redirected to after deleting things | ||||
|  */ | ||||
| function opencase_cases_form_alter(&$form, &$form_state, $form_id) { | ||||
|   if (preg_match('/oc_actor_.*_delete_form/', $form_id) or (preg_match('/oc_case_.*_delete_form/', $form_id)) or (preg_match('/oc_organisation_.*_delete_form/', $form_id))) { | ||||
|     $form['actions']['submit']['#submit'][] = '_opencase_cases_redirect_to_home'; | ||||
|     $form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl(); | ||||
|   } | ||||
|   if (preg_match('/oc_activity_.*_delete_form/', $form_id)) { | ||||
|     $form['actions']['submit']['#submit'][] = '_opencase_cases_delete_activity_redirect'; | ||||
|     $form['actions']['cancel']['#url'] = $form_state->getFormObject()->getEntity()->toUrl(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| function _opencase_cases_redirect_to_home($form, &$form_state) { | ||||
|   $form_state->setRedirect('<front>');  | ||||
| } | ||||
|  | ||||
| // Upon deletion of an activity, go to the related case if there is one, otherwise to its target. | ||||
| function _opencase_cases_delete_activity_redirect($form, &$form_state) { | ||||
|   if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) { | ||||
|     $case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id; | ||||
|     $form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]); | ||||
|   } else { | ||||
|     $target_actor_id = $form_state->getFormObject()->getEntity()->oc_target->target_id; | ||||
|     $form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]); | ||||
|   } | ||||
| } | ||||
| /** | ||||
| * Implements hook_theme_suggestions_HOOK(). | ||||
| */ | ||||
| function opencase_cases_theme_suggestions_oc_case(array $variables) { | ||||
|   $suggestions = []; | ||||
|   $entity = $variables['elements']['#oc_case']; | ||||
|   $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_'); | ||||
|  | ||||
|   $suggestions[] = 'oc_case__' . $sanitized_view_mode; | ||||
|   $suggestions[] = 'oc_case__' . $entity->bundle(); | ||||
|   $suggestions[] = 'oc_case__' . $entity->bundle() . '__' . $sanitized_view_mode; | ||||
|   $suggestions[] = 'oc_case__' . $entity->id(); | ||||
|   $suggestions[] = 'oc_case__' . $entity->id() . '__' . $sanitized_view_mode; | ||||
|   return $suggestions; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * 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; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Implements hook_theme_suggestions_HOOK(). | ||||
|  */ | ||||
| function opencase_cases_theme_suggestions_oc_case_fee(array $variables) { | ||||
|   $suggestions = []; | ||||
|   $entity = $variables['elements']['#oc_case_fee']; | ||||
|   $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_'); | ||||
|  | ||||
|   $suggestions[] = 'oc_case_fee__' . $sanitized_view_mode; | ||||
|   $suggestions[] = 'oc_case_fee__' . $entity->bundle(); | ||||
|   $suggestions[] = 'oc_case_fee__' . $entity->bundle() . '__' . $sanitized_view_mode; | ||||
|   $suggestions[] = 'oc_case_fee__' . $entity->id(); | ||||
|   $suggestions[] = 'oc_case_fee__' . $entity->id() . '__' . $sanitized_view_mode; | ||||
|   return $suggestions; | ||||
| } | ||||
							
								
								
									
										61
									
								
								modules/opencase_cases/opencase_cases.permissions.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								modules/opencase_cases/opencase_cases.permissions.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,61 @@ | ||||
| add case provision entities: | ||||
|   title: 'Create new Case Provision entities' | ||||
|  | ||||
| administer case provision entities: | ||||
|   title: 'Administer Case Provision entities' | ||||
|   description: 'Allow to access the administration form to configure Case Provision entities.' | ||||
|   restrict access: true | ||||
|  | ||||
| delete case provision entities: | ||||
|   title: 'Delete Case Provision entities' | ||||
|  | ||||
| edit case provision entities: | ||||
|   title: 'Edit Case Provision entities' | ||||
|  | ||||
| view published case provision entities: | ||||
|   title: 'View published Case Provision entities' | ||||
|  | ||||
| view unpublished case provision entities: | ||||
|   title: 'View unpublished Case Provision entities' | ||||
|  | ||||
| view all case provision revisions: | ||||
|   title: 'View all Case Provision revisions' | ||||
|  | ||||
| revert all case provision revisions: | ||||
|   title: 'Revert all Case Provision revisions' | ||||
|   description: 'Role requires permission <em>view Case Provision revisions</em> and <em>edit rights</em> for case provision entities in question or <em>administer case provision entities</em>.' | ||||
|  | ||||
| delete all case provision revisions: | ||||
|   title: 'Delete all revisions' | ||||
|   description: 'Role requires permission to <em>view Case Provision revisions</em> and <em>delete rights</em> for case provision entities in question or <em>administer case provision entities</em>.' | ||||
|  | ||||
| add case fee entities: | ||||
|   title: 'Create new Case Fee entities' | ||||
|  | ||||
| administer case fee entities: | ||||
|   title: 'Administer Case Fee entities' | ||||
|   description: 'Allow to access the administration form to configure Case Fee entities.' | ||||
|   restrict access: true | ||||
|  | ||||
| delete case fee entities: | ||||
|   title: 'Delete Case Fee entities' | ||||
|  | ||||
| edit case fee entities: | ||||
|   title: 'Edit Case Fee entities' | ||||
|  | ||||
| view published case fee entities: | ||||
|   title: 'View published Case Fee entities' | ||||
|  | ||||
| view unpublished case fee entities: | ||||
|   title: 'View unpublished Case Fee entities' | ||||
|  | ||||
| view all case fee revisions: | ||||
|   title: 'View all Case Fee revisions' | ||||
|  | ||||
| revert all case fee revisions: | ||||
|   title: 'Revert all Case Fee revisions' | ||||
|   description: 'Role requires permission <em>view Case Fee revisions</em> and <em>edit rights</em> for case fee entities in question or <em>administer case fee entities</em>.' | ||||
|  | ||||
| delete all case fee revisions: | ||||
|   title: 'Delete all revisions' | ||||
|   description: 'Role requires permission to <em>view Case Fee revisions</em> and <em>delete rights</em> for case fee entities in question or <em>administer case fee entities</em>.' | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| class CaseInvolvement { | ||||
| 
 | ||||
| @ -10,8 +10,11 @@ class CaseInvolvement { | ||||
| 
 | ||||
|   public static function userIsInvolved($account, $case) { | ||||
|     $actorId = self::getLinkedActorId($account);         | ||||
|     $involvedIds = array_column($case->actors_involved->getValue(), 'target_id'); | ||||
|     return in_array($actorId, $involvedIds); | ||||
|     $query = \Drupal::entityQuery('oc_case_provision') | ||||
|     ->condition('oc_provider', $actorId) | ||||
|     ->condition('oc_case', $case->id()); | ||||
|     $results = $query->execute(); | ||||
|     return !empty($results); | ||||
|   } | ||||
| 
 | ||||
|   public static function userIsInvolved_activity($account, $activity) { | ||||
| @ -1,12 +1,12 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Controller; | ||||
| namespace Drupal\opencase_cases\Controller; | ||||
| 
 | ||||
| use Drupal\Component\Utility\Xss; | ||||
| use Drupal\Core\Controller\ControllerBase; | ||||
| use Drupal\Core\DependencyInjection\ContainerInjectionInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseInterface; | ||||
| 
 | ||||
| /** | ||||
|  * Class OCCaseController. | ||||
| @ -25,8 +25,8 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter | ||||
|    *   An array suitable for drupal_render(). | ||||
|    */ | ||||
|   public function revisionShow($oc_case_revision) { | ||||
|     $oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision); | ||||
|     $view_builder = $this->entityManager()->getViewBuilder('oc_case'); | ||||
|     $oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision); | ||||
|     $view_builder = $this->entityTypeManager()->getViewBuilder('oc_case'); | ||||
| 
 | ||||
|     return $view_builder->view($oc_case); | ||||
|   } | ||||
| @ -41,14 +41,16 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter | ||||
|    *   The page title. | ||||
|    */ | ||||
|   public function revisionPageTitle($oc_case_revision) { | ||||
|     $oc_case = $this->entityManager()->getStorage('oc_case')->loadRevision($oc_case_revision); | ||||
|     return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => format_date($oc_case->getRevisionCreationTime())]); | ||||
|     $oc_case = $this->entityTypeManager()->getStorage('oc_case')->loadRevision($oc_case_revision); | ||||
| 
 | ||||
|     $date = \Drupal::service('date.formatter')->format($oc_case->getRevisionCreationTime()); | ||||
|     return $this->t('Revision of %title from %date', ['%title' => $oc_case->label(), '%date' => $date]); | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * Generates an overview table of older revisions of a Case . | ||||
|    * | ||||
|    * @param \Drupal\opencase_entities\Entity\OCCaseInterface $oc_case | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseInterface $oc_case | ||||
|    *   A Case  object. | ||||
|    * | ||||
|    * @return array | ||||
| @ -60,7 +62,7 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter | ||||
|     $langname = $oc_case->language()->getName(); | ||||
|     $languages = $oc_case->getTranslationLanguages(); | ||||
|     $has_translations = (count($languages) > 1); | ||||
|     $oc_case_storage = $this->entityManager()->getStorage('oc_case'); | ||||
|     $oc_case_storage = $this->entityTypeManager()->getStorage('oc_case'); | ||||
| 
 | ||||
|     $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case->label()]); | ||||
|     $header = [$this->t('Revision'), $this->t('Operations')]; | ||||
| @ -75,7 +77,7 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter | ||||
|     $latest_revision = TRUE; | ||||
| 
 | ||||
|     foreach (array_reverse($vids) as $vid) { | ||||
|       /** @var \Drupal\opencase_entities\OCCaseInterface $revision */ | ||||
|       /** @var \Drupal\opencase_cases\OCCaseInterface $revision */ | ||||
|       $revision = $oc_case_storage->loadRevision($vid); | ||||
|       // Only show revisions that are affected by the language that is being
 | ||||
|       // displayed.
 | ||||
| @ -88,10 +90,11 @@ class OCCaseController extends ControllerBase implements ContainerInjectionInter | ||||
|         // Use revision link to link to revisions that are not active.
 | ||||
|         $date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short'); | ||||
|         if ($vid != $oc_case->getRevisionId()) { | ||||
|           $link = $this->l($date, new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid])); | ||||
|           $url =  new Url('entity.oc_case.revision', ['oc_case' => $oc_case->id(), 'oc_case_revision' => $vid]); | ||||
|           $link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString(); | ||||
|         } | ||||
|         else { | ||||
|           $link = $oc_case->link($date); | ||||
|           $link = $oc_case->toLink($date)->toString(); | ||||
|         } | ||||
| 
 | ||||
|         $row = []; | ||||
							
								
								
									
										210
									
								
								modules/opencase_cases/src/Controller/OCCaseFeeController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										210
									
								
								modules/opencase_cases/src/Controller/OCCaseFeeController.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,210 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Controller; | ||||
|  | ||||
| use Drupal\Component\Utility\Xss; | ||||
| use Drupal\Core\Controller\ControllerBase; | ||||
| use Drupal\Core\DependencyInjection\ContainerInjectionInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFeeInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseFeeController. | ||||
|  * | ||||
|  *  Returns responses for Case Fee routes. | ||||
|  */ | ||||
| class OCCaseFeeController extends ControllerBase implements ContainerInjectionInterface { | ||||
|  | ||||
|   /** | ||||
|    * The date formatter. | ||||
|    * | ||||
|    * @var \Drupal\Core\Datetime\DateFormatter | ||||
|    */ | ||||
|   protected $dateFormatter; | ||||
|  | ||||
|   /** | ||||
|    * The renderer. | ||||
|    * | ||||
|    * @var \Drupal\Core\Render\Renderer | ||||
|    */ | ||||
|   protected $renderer; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->dateFormatter = $container->get('date.formatter'); | ||||
|     $instance->renderer = $container->get('renderer'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Displays a Case Fee revision. | ||||
|    * | ||||
|    * @param int $oc_case_fee_revision | ||||
|    *   The Case Fee revision ID. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An array suitable for drupal_render(). | ||||
|    */ | ||||
|   public function revisionShow($oc_case_fee_revision) { | ||||
|     $oc_case_fee = $this->entityTypeManager()->getStorage('oc_case_fee') | ||||
|       ->loadRevision($oc_case_fee_revision); | ||||
|     $view_builder = $this->entityTypeManager()->getViewBuilder('oc_case_fee'); | ||||
|  | ||||
|     return $view_builder->view($oc_case_fee); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Page title callback for a Case Fee revision. | ||||
|    * | ||||
|    * @param int $oc_case_fee_revision | ||||
|    *   The Case Fee revision ID. | ||||
|    * | ||||
|    * @return string | ||||
|    *   The page title. | ||||
|    */ | ||||
|   public function revisionPageTitle($oc_case_fee_revision) { | ||||
|     $oc_case_fee = $this->entityTypeManager()->getStorage('oc_case_fee') | ||||
|       ->loadRevision($oc_case_fee_revision); | ||||
|     return $this->t('Revision of %title from %date', [ | ||||
|       '%title' => $oc_case_fee->label(), | ||||
|       '%date' => $this->dateFormatter->format($oc_case_fee->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Generates an overview table of older revisions of a Case Fee. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $oc_case_fee | ||||
|    *   A Case Fee object. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An array as expected by drupal_render(). | ||||
|    */ | ||||
|   public function revisionOverview(OCCaseFeeInterface $oc_case_fee) { | ||||
|     $account = $this->currentUser(); | ||||
|     $oc_case_fee_storage = $this->entityTypeManager()->getStorage('oc_case_fee'); | ||||
|  | ||||
|     $langcode = $oc_case_fee->language()->getId(); | ||||
|     $langname = $oc_case_fee->language()->getName(); | ||||
|     $languages = $oc_case_fee->getTranslationLanguages(); | ||||
|     $has_translations = (count($languages) > 1); | ||||
|     $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case_fee->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case_fee->label()]); | ||||
|  | ||||
|     $header = [$this->t('Revision'), $this->t('Operations')]; | ||||
|     $revert_permission = (($account->hasPermission("revert all case fee revisions") || $account->hasPermission('administer case fee entities'))); | ||||
|     $delete_permission = (($account->hasPermission("delete all case fee revisions") || $account->hasPermission('administer case fee entities'))); | ||||
|  | ||||
|     $rows = []; | ||||
|  | ||||
|     $vids = $oc_case_fee_storage->revisionIds($oc_case_fee); | ||||
|  | ||||
|     $latest_revision = TRUE; | ||||
|  | ||||
|     foreach (array_reverse($vids) as $vid) { | ||||
|       /** @var \Drupal\opencase_cases\OCCaseFeeInterface $revision */ | ||||
|       $revision = $oc_case_fee_storage->loadRevision($vid); | ||||
|       // Only show revisions that are affected by the language that is being | ||||
|       // displayed. | ||||
|       if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) { | ||||
|         $username = [ | ||||
|           '#theme' => 'username', | ||||
|           '#account' => $revision->getRevisionUser(), | ||||
|         ]; | ||||
|  | ||||
|         // Use revision link to link to revisions that are not active. | ||||
|         $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short'); | ||||
|         if ($vid != $oc_case_fee->getRevisionId()) { | ||||
|           $url = new Url('entity.oc_case_fee.revision', [ | ||||
|             'oc_case_fee' => $oc_case_fee->id(), | ||||
|             'oc_case_fee_revision' => $vid, | ||||
|           ]); | ||||
|           $link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString(); | ||||
|         } | ||||
|         else { | ||||
|           $link = $oc_case_fee->toLink($date)->toString(); | ||||
|         } | ||||
|  | ||||
|         $row = []; | ||||
|         $column = [ | ||||
|           'data' => [ | ||||
|             '#type' => 'inline_template', | ||||
|             '#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}', | ||||
|             '#context' => [ | ||||
|               'date' => $link, | ||||
|               'username' => $this->renderer->renderPlain($username), | ||||
|               'message' => [ | ||||
|                 '#markup' => $revision->getRevisionLogMessage(), | ||||
|                 '#allowed_tags' => Xss::getHtmlTagList(), | ||||
|               ], | ||||
|             ], | ||||
|           ], | ||||
|         ]; | ||||
|         $row[] = $column; | ||||
|  | ||||
|         if ($latest_revision) { | ||||
|           $row[] = [ | ||||
|             'data' => [ | ||||
|               '#prefix' => '<em>', | ||||
|               '#markup' => $this->t('Current revision'), | ||||
|               '#suffix' => '</em>', | ||||
|             ], | ||||
|           ]; | ||||
|           foreach ($row as &$current) { | ||||
|             $current['class'] = ['revision-current']; | ||||
|           } | ||||
|           $latest_revision = FALSE; | ||||
|         } | ||||
|         else { | ||||
|           $links = []; | ||||
|           if ($revert_permission) { | ||||
|             $links['revert'] = [ | ||||
|               'title' => $this->t('Revert'), | ||||
|               'url' => $has_translations ? | ||||
|               Url::fromRoute('entity.oc_case_fee.translation_revert', [ | ||||
|                 'oc_case_fee' => $oc_case_fee->id(), | ||||
|                 'oc_case_fee_revision' => $vid, | ||||
|                 'langcode' => $langcode, | ||||
|               ]) : | ||||
|               Url::fromRoute('entity.oc_case_fee.revision_revert', [ | ||||
|                 'oc_case_fee' => $oc_case_fee->id(), | ||||
|                 'oc_case_fee_revision' => $vid, | ||||
|               ]), | ||||
|             ]; | ||||
|           } | ||||
|  | ||||
|           if ($delete_permission) { | ||||
|             $links['delete'] = [ | ||||
|               'title' => $this->t('Delete'), | ||||
|               'url' => Url::fromRoute('entity.oc_case_fee.revision_delete', [ | ||||
|                 'oc_case_fee' => $oc_case_fee->id(), | ||||
|                 'oc_case_fee_revision' => $vid, | ||||
|               ]), | ||||
|             ]; | ||||
|           } | ||||
|  | ||||
|           $row[] = [ | ||||
|             'data' => [ | ||||
|               '#type' => 'operations', | ||||
|               '#links' => $links, | ||||
|             ], | ||||
|           ]; | ||||
|         } | ||||
|  | ||||
|         $rows[] = $row; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     $build['oc_case_fee_revisions_table'] = [ | ||||
|       '#theme' => 'table', | ||||
|       '#rows' => $rows, | ||||
|       '#header' => $header, | ||||
|     ]; | ||||
|  | ||||
|     return $build; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,210 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Controller; | ||||
|  | ||||
| use Drupal\Component\Utility\Xss; | ||||
| use Drupal\Core\Controller\ControllerBase; | ||||
| use Drupal\Core\DependencyInjection\ContainerInjectionInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvisionInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseProvisionController. | ||||
|  * | ||||
|  *  Returns responses for Case Provision routes. | ||||
|  */ | ||||
| class OCCaseProvisionController extends ControllerBase implements ContainerInjectionInterface { | ||||
|  | ||||
|   /** | ||||
|    * The date formatter. | ||||
|    * | ||||
|    * @var \Drupal\Core\Datetime\DateFormatter | ||||
|    */ | ||||
|   protected $dateFormatter; | ||||
|  | ||||
|   /** | ||||
|    * The renderer. | ||||
|    * | ||||
|    * @var \Drupal\Core\Render\Renderer | ||||
|    */ | ||||
|   protected $renderer; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->dateFormatter = $container->get('date.formatter'); | ||||
|     $instance->renderer = $container->get('renderer'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Displays a Case Provision revision. | ||||
|    * | ||||
|    * @param int $oc_case_provision_revision | ||||
|    *   The Case Provision revision ID. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An array suitable for drupal_render(). | ||||
|    */ | ||||
|   public function revisionShow($oc_case_provision_revision) { | ||||
|     $oc_case_provision = $this->entityTypeManager()->getStorage('oc_case_provision') | ||||
|       ->loadRevision($oc_case_provision_revision); | ||||
|     $view_builder = $this->entityTypeManager()->getViewBuilder('oc_case_provision'); | ||||
|  | ||||
|     return $view_builder->view($oc_case_provision); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Page title callback for a Case Provision revision. | ||||
|    * | ||||
|    * @param int $oc_case_provision_revision | ||||
|    *   The Case Provision revision ID. | ||||
|    * | ||||
|    * @return string | ||||
|    *   The page title. | ||||
|    */ | ||||
|   public function revisionPageTitle($oc_case_provision_revision) { | ||||
|     $oc_case_provision = $this->entityTypeManager()->getStorage('oc_case_provision') | ||||
|       ->loadRevision($oc_case_provision_revision); | ||||
|     return $this->t('Revision of %title from %date', [ | ||||
|       '%title' => $oc_case_provision->label(), | ||||
|       '%date' => $this->dateFormatter->format($oc_case_provision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Generates an overview table of older revisions of a Case Provision. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $oc_case_provision | ||||
|    *   A Case Provision object. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An array as expected by drupal_render(). | ||||
|    */ | ||||
|   public function revisionOverview(OCCaseProvisionInterface $oc_case_provision) { | ||||
|     $account = $this->currentUser(); | ||||
|     $oc_case_provision_storage = $this->entityTypeManager()->getStorage('oc_case_provision'); | ||||
|  | ||||
|     $langcode = $oc_case_provision->language()->getId(); | ||||
|     $langname = $oc_case_provision->language()->getName(); | ||||
|     $languages = $oc_case_provision->getTranslationLanguages(); | ||||
|     $has_translations = (count($languages) > 1); | ||||
|     $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $oc_case_provision->label()]) : $this->t('Revisions for %title', ['%title' => $oc_case_provision->label()]); | ||||
|  | ||||
|     $header = [$this->t('Revision'), $this->t('Operations')]; | ||||
|     $revert_permission = (($account->hasPermission("revert all case provision revisions") || $account->hasPermission('administer case provision entities'))); | ||||
|     $delete_permission = (($account->hasPermission("delete all case provision revisions") || $account->hasPermission('administer case provision entities'))); | ||||
|  | ||||
|     $rows = []; | ||||
|  | ||||
|     $vids = $oc_case_provision_storage->revisionIds($oc_case_provision); | ||||
|  | ||||
|     $latest_revision = TRUE; | ||||
|  | ||||
|     foreach (array_reverse($vids) as $vid) { | ||||
|       /** @var \Drupal\opencase_cases\OCCaseProvisionInterface $revision */ | ||||
|       $revision = $oc_case_provision_storage->loadRevision($vid); | ||||
|       // Only show revisions that are affected by the language that is being | ||||
|       // displayed. | ||||
|       if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) { | ||||
|         $username = [ | ||||
|           '#theme' => 'username', | ||||
|           '#account' => $revision->getRevisionUser(), | ||||
|         ]; | ||||
|  | ||||
|         // Use revision link to link to revisions that are not active. | ||||
|         $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short'); | ||||
|         if ($vid != $oc_case_provision->getRevisionId()) { | ||||
|           $url = new Url('entity.oc_case_provision.revision', [ | ||||
|             'oc_case_provision' => $oc_case_provision->id(), | ||||
|             'oc_case_provision_revision' => $vid, | ||||
|           ]); | ||||
|           $link = \Drupal\Core\Link::fromTextAndUrl($date, $url)->toString(); | ||||
|         } | ||||
|         else { | ||||
|           $link = $oc_case_provision->toLink($date)->toString(); | ||||
|         } | ||||
|  | ||||
|         $row = []; | ||||
|         $column = [ | ||||
|           'data' => [ | ||||
|             '#type' => 'inline_template', | ||||
|             '#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}', | ||||
|             '#context' => [ | ||||
|               'date' => $link, | ||||
|               'username' => $this->renderer->renderPlain($username), | ||||
|               'message' => [ | ||||
|                 '#markup' => $revision->getRevisionLogMessage(), | ||||
|                 '#allowed_tags' => Xss::getHtmlTagList(), | ||||
|               ], | ||||
|             ], | ||||
|           ], | ||||
|         ]; | ||||
|         $row[] = $column; | ||||
|  | ||||
|         if ($latest_revision) { | ||||
|           $row[] = [ | ||||
|             'data' => [ | ||||
|               '#prefix' => '<em>', | ||||
|               '#markup' => $this->t('Current revision'), | ||||
|               '#suffix' => '</em>', | ||||
|             ], | ||||
|           ]; | ||||
|           foreach ($row as &$current) { | ||||
|             $current['class'] = ['revision-current']; | ||||
|           } | ||||
|           $latest_revision = FALSE; | ||||
|         } | ||||
|         else { | ||||
|           $links = []; | ||||
|           if ($revert_permission) { | ||||
|             $links['revert'] = [ | ||||
|               'title' => $this->t('Revert'), | ||||
|               'url' => $has_translations ? | ||||
|               Url::fromRoute('entity.oc_case_provision.translation_revert', [ | ||||
|                 'oc_case_provision' => $oc_case_provision->id(), | ||||
|                 'oc_case_provision_revision' => $vid, | ||||
|                 'langcode' => $langcode, | ||||
|               ]) : | ||||
|               Url::fromRoute('entity.oc_case_provision.revision_revert', [ | ||||
|                 'oc_case_provision' => $oc_case_provision->id(), | ||||
|                 'oc_case_provision_revision' => $vid, | ||||
|               ]), | ||||
|             ]; | ||||
|           } | ||||
|  | ||||
|           if ($delete_permission) { | ||||
|             $links['delete'] = [ | ||||
|               'title' => $this->t('Delete'), | ||||
|               'url' => Url::fromRoute('entity.oc_case_provision.revision_delete', [ | ||||
|                 'oc_case_provision' => $oc_case_provision->id(), | ||||
|                 'oc_case_provision_revision' => $vid, | ||||
|               ]), | ||||
|             ]; | ||||
|           } | ||||
|  | ||||
|           $row[] = [ | ||||
|             'data' => [ | ||||
|               '#type' => 'operations', | ||||
|               '#links' => $links, | ||||
|             ], | ||||
|           ]; | ||||
|         } | ||||
|  | ||||
|         $rows[] = $row; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     $build['oc_case_provision_revisions_table'] = [ | ||||
|       '#theme' => 'table', | ||||
|       '#rows' => $rows, | ||||
|       '#header' => $header, | ||||
|     ]; | ||||
|  | ||||
|     return $build; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Entity; | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| use Drupal\Core\Field\BaseFieldDefinition; | ||||
| @ -13,34 +13,39 @@ use Drupal\user\UserInterface; | ||||
| /** | ||||
|  * Defines the Case entity. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  * | ||||
|  * @ContentEntityType( | ||||
|  *   id = "oc_case", | ||||
|  *   label = @Translation("Case"), | ||||
|  *   bundle_label = @Translation("Case type"), | ||||
|  *   handlers = { | ||||
|  *     "storage" = "Drupal\opencase_entities\OCCaseStorage", | ||||
|  *     "storage" = "Drupal\opencase_cases\OCCaseStorage", | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_entities\OCCaseListBuilder", | ||||
|  *     "views_data" = "Drupal\opencase_entities\Entity\OCCaseViewsData", | ||||
|  *     "translation" = "Drupal\opencase_entities\OCCaseTranslationHandler", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseListBuilder", | ||||
|  *     "views_data" = "Drupal\opencase_cases\Entity\OCCaseViewsData", | ||||
|  *     "translation" = "Drupal\opencase_cases\OCCaseTranslationHandler", | ||||
|  * | ||||
|  *     "form" = { | ||||
|  *       "default" = "Drupal\opencase_entities\Form\OCCaseForm", | ||||
|  *       "add" = "Drupal\opencase_entities\Form\OCCaseForm", | ||||
|  *       "edit" = "Drupal\opencase_entities\Form\OCCaseForm", | ||||
|  *       "delete" = "Drupal\opencase_entities\Form\OCCaseDeleteForm", | ||||
|  *       "default" = "Drupal\opencase_cases\Form\OCCaseForm", | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseDeleteForm", | ||||
|  *     }, | ||||
|  *     "access" = "Drupal\opencase_entities\OCCaseAccessControlHandler", | ||||
|  *     "access" = "Drupal\opencase_cases\OCCaseAccessControlHandler", | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_entities\OCCaseHtmlRouteProvider", | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *   }, | ||||
|  *   base_table = "oc_case", | ||||
|  *   data_table = "oc_case_field_data", | ||||
|  *   revision_table = "oc_case_revision", | ||||
|  *   revision_data_table = "oc_case_field_revision", | ||||
|  *   revision_metadata_keys = { | ||||
|  *     "revision_user" = "revision_user", | ||||
|  *     "revision_created" = "revision_created", | ||||
|  *     "revision_log_message" = "revision_log" | ||||
|  *   }, | ||||
|  *   translatable = TRUE, | ||||
|  *   admin_permission = "administer case entities", | ||||
|  *   entity_keys = { | ||||
| @ -74,17 +79,6 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
| 
 | ||||
|   use EntityChangedTrait; | ||||
| 
 | ||||
|   /** | ||||
|    * When creating a case, it sets the first involved party to the actor | ||||
|    * id from the URL, and the second to the author's linked actor  | ||||
|    * (if it exists and is different) | ||||
|    */ | ||||
|   public static function defaultVal() { | ||||
|     $author_linked_actor_id = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id())->get('field_linked_opencase_actor')->target_id; | ||||
|     $currently_viewed_actor_id = \Drupal::request()->query->get('actor_id'); | ||||
|     return array_unique([$currently_viewed_actor_id, $author_linked_actor_id]); | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
| @ -95,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} | ||||
|    */ | ||||
| @ -208,6 +208,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
|     return $this; | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|    | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
| @ -216,66 +218,55 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
| 
 | ||||
|     // not currently used. Will add form and view settings when ready
 | ||||
|     $fields['status'] = BaseFieldDefinition::create('boolean') | ||||
|       ->setLabel(t('Publishing status')) | ||||
|       ->setDescription(t('A boolean indicating whether the Case is published.')) | ||||
|       ->setLabel(t('Visible')) | ||||
|       ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.') | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setDisplayConfigurable("form", TRUE) | ||||
|       ->setDefaultValue(TRUE); | ||||
| 
 | ||||
|     $fields['user_id'] = BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Entered by')) | ||||
|       ->setLabel(t('Created by')) | ||||
|       ->setDescription(t('The user ID of author of the Case entity.')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSetting('target_type', 'user') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setDisplayConfigurable('form', true) | ||||
|       ->setDisplayConfigurable('view', true) | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'inline', | ||||
|         'label' => 'above', | ||||
|         'type' => 'author', | ||||
|         'weight' => -4, | ||||
|         '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('Case Title')) | ||||
|       ->setDescription(t('A short phrase summing up what this case is about.')) | ||||
|       ->setLabel(t('Title')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSettings([ | ||||
|         'max_length' => 50, | ||||
|         'max_length' => 120, | ||||
|         'text_processing' => 0, | ||||
|       ]) | ||||
|       ->setDefaultValue('') | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'hidden', | ||||
|         'type' => 'string', | ||||
|         'weight' => -3, | ||||
|       ]) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'string_textfield', | ||||
|         'weight' => -3, | ||||
|         'weight' => -100, | ||||
|       ]) | ||||
|       ->setRequired(TRUE); | ||||
| 
 | ||||
|     $fields['actors_involved'] = BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Involved Parties')) | ||||
|       ->setDescription(t('People involved in this case. To add one, start typing their name.')) | ||||
|       ->setSetting('target_type', 'oc_actor') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(-1) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'entity_reference_autocomplete', | ||||
|         'weight' => -2, | ||||
|         'settings' => [ | ||||
|           'match_operator' => 'CONTAINS', | ||||
|           'size' => '60', | ||||
|           'autocomplete_type' => 'tags', | ||||
|           'placeholder' => '', | ||||
|         ], | ||||
|       ]) | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'above', | ||||
|         'weight' => -2 | ||||
|       ]) | ||||
|       ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCCase::defaultVal') | ||||
|       ->setRequired(TRUE); | ||||
| 
 | ||||
|     $fields['files'] = BaseFieldDefinition::create('file') | ||||
|       ->setLabel(t('Files')) | ||||
| @ -286,6 +277,8 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
|       ->setSetting('description_field', 'true') | ||||
|       ->setSetting('uri_scheme', 'private') | ||||
|       ->setCardinality(-1) | ||||
|       ->setDisplayConfigurable('form', true) | ||||
|       ->setDisplayConfigurable('view', true) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'file_generic', | ||||
|         'weight' => -1, | ||||
| @ -295,17 +288,18 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
|       ]) | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'above', | ||||
|         'weight' => -1, | ||||
|         'settings' => ['use_description_as_link_text' => 'true'] | ||||
|       ]); | ||||
| 
 | ||||
|     $fields['created'] = BaseFieldDefinition::create('created') | ||||
|       ->setLabel(t('Created')) | ||||
|       ->setDescription(t('The time that the entity was created.')); | ||||
|       ->setLabel(t('Created on')) | ||||
|       ->setDescription(t('When the case was created.')) | ||||
|       ->setDisplayConfigurable('view', true); | ||||
| 
 | ||||
|     $fields['changed'] = BaseFieldDefinition::create('changed') | ||||
|       ->setLabel(t('Changed')) | ||||
|       ->setDescription(t('The time that the entity was last edited.')); | ||||
|       ->setLabel(t('Last updated')) | ||||
|       ->setDescription(t('When the case was last edited.')) | ||||
|       ->setDisplayConfigurable('view', true); | ||||
| 
 | ||||
|     $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean') | ||||
|       ->setLabel(t('Revision translation affected')) | ||||
| @ -314,6 +308,26 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setTranslatable(TRUE); | ||||
| 
 | ||||
|     $fields['notes'] = BaseFieldDefinition::create('string_long') | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setLabel(t('Notes')) | ||||
|       ->setSettings(array( | ||||
|         'default_value' => '', | ||||
|         'max_length' => 255, | ||||
|         'text_processing' => 0, | ||||
|       )) | ||||
|       ->setDisplayConfigurable('form', true) | ||||
|       ->setDisplayConfigurable('view', true); | ||||
| 
 | ||||
| 
 | ||||
|     $fields['total_fee'] = BaseFieldDefinition::create('decimal') | ||||
|     ->setLabel(t('Total Fee')) | ||||
|     ->setRevisionable(TRUE) | ||||
|     ->setSettings([ | ||||
|       'prefix' => '£', | ||||
|     ]) | ||||
|     ->SetDisplayConfigurable("view", true); | ||||
| 
 | ||||
|     return $fields; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										303
									
								
								modules/opencase_cases/src/Entity/OCCaseFee.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										303
									
								
								modules/opencase_cases/src/Entity/OCCaseFee.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,303 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| use Drupal\Core\Field\BaseFieldDefinition; | ||||
| use Drupal\Core\Entity\EditorialContentEntityBase; | ||||
| use Drupal\Core\Entity\RevisionableInterface; | ||||
| use Drupal\Core\Entity\EntityChangedTrait; | ||||
| use Drupal\Core\Entity\EntityPublishedTrait; | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\user\UserInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the Case Fee entity. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  * | ||||
|  * @ContentEntityType( | ||||
|  *   id = "oc_case_fee", | ||||
|  *   label = @Translation("Case Fee"), | ||||
|  *   bundle_label = @Translation("Case Fee type"), | ||||
|  *   handlers = { | ||||
|  *     "storage" = "Drupal\opencase_cases\OCCaseFeeStorage", | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseFeeListBuilder", | ||||
|  *     "views_data" = "Drupal\opencase_cases\Entity\OCCaseFeeViewsData", | ||||
|  *     "translation" = "Drupal\opencase_cases\OCCaseFeeTranslationHandler", | ||||
|  * | ||||
|  *     "form" = { | ||||
|  *       "default" = "Drupal\opencase_cases\Form\OCCaseFeeForm", | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseFeeForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseFeeForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseFeeDeleteForm", | ||||
|  *     }, | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseFeeHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *     "access" = "Drupal\opencase_cases\OCCaseFeeAccessControlHandler", | ||||
|  *   }, | ||||
|  *   base_table = "oc_case_fee", | ||||
|  *   data_table = "oc_case_fee_field_data", | ||||
|  *   revision_table = "oc_case_fee_revision", | ||||
|  *   revision_data_table = "oc_case_fee_field_revision", | ||||
|  *   translatable = TRUE, | ||||
|  *   permission_granularity = "bundle", | ||||
|  *   admin_permission = "administer case fee entities", | ||||
|  *   entity_keys = { | ||||
|  *     "id" = "id", | ||||
|  *     "revision" = "vid", | ||||
|  *     "bundle" = "type", | ||||
|  *     "label" = "name", | ||||
|  *     "uuid" = "uuid", | ||||
|  *     "uid" = "user_id", | ||||
|  *     "langcode" = "langcode", | ||||
|  *     "published" = "status", | ||||
|  *   }, | ||||
|  *   revision_metadata_keys = { | ||||
|  *     "revision_user" = "revision_user", | ||||
|  *     "revision_created" = "revision_created", | ||||
|  *     "revision_log_message" = "revision_log", | ||||
|  *   }, | ||||
|  *   links = { | ||||
|  *     "canonical" = "/opencase/oc_case_fee/{oc_case_fee}", | ||||
|  *     "add-page" = "/opencase/oc_case_fee/add", | ||||
|  *     "add-form" = "/opencase/oc_case_fee/add/{oc_case_fee_type}", | ||||
|  *     "edit-form" = "/opencase/oc_case_fee/{oc_case_fee}/edit", | ||||
|  *     "delete-form" = "/opencase/oc_case_fee/{oc_case_fee}/delete", | ||||
|  *     "version-history" = "/opencase/oc_case_fee/{oc_case_fee}/revisions", | ||||
|  *     "revision" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/view", | ||||
|  *     "revision_revert" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/revert", | ||||
|  *     "revision_delete" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/delete", | ||||
|  *     "translation_revert" = "/opencase/oc_case_fee/{oc_case_fee}/revisions/{oc_case_fee_revision}/revert/{langcode}", | ||||
|  *     "collection" = "/opencase/oc_case_fee", | ||||
|  *   }, | ||||
|  *   bundle_entity_type = "oc_case_fee_type", | ||||
|  *   field_ui_base_route = "entity.oc_case_fee_type.edit_form" | ||||
|  * ) | ||||
|  */ | ||||
| class OCCaseFee extends EditorialContentEntityBase implements OCCaseFeeInterface { | ||||
|  | ||||
|   use EntityChangedTrait; | ||||
|   use EntityPublishedTrait; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function preCreate(EntityStorageInterface $storage_controller, array &$values) { | ||||
|     parent::preCreate($storage_controller, $values); | ||||
|     $values += [ | ||||
|       'user_id' => \Drupal::currentUser()->id(), | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function urlRouteParameters($rel) { | ||||
|     $uri_route_parameters = parent::urlRouteParameters($rel); | ||||
|  | ||||
|     if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) { | ||||
|       $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); | ||||
|     } | ||||
|     elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) { | ||||
|       $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); | ||||
|     } | ||||
|  | ||||
|     return $uri_route_parameters; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function preSave(EntityStorageInterface $storage) { | ||||
|     parent::preSave($storage); | ||||
|  | ||||
|     foreach (array_keys($this->getTranslationLanguages()) as $langcode) { | ||||
|       $translation = $this->getTranslation($langcode); | ||||
|  | ||||
|       // If no owner has been set explicitly, make the anonymous user the owner. | ||||
|       if (!$translation->getOwner()) { | ||||
|         $translation->setOwnerId(0); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     // If no revision author has been set explicitly, | ||||
|     // make the oc_case_fee owner the revision author. | ||||
|     if (!$this->getRevisionUser()) { | ||||
|       $this->setRevisionUserId($this->getOwnerId()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getName() { | ||||
|     return $this->get('name')->value; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setName($name) { | ||||
|     $this->set('name', $name); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCreatedTime() { | ||||
|     return $this->get('created')->value; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setCreatedTime($timestamp) { | ||||
|     $this->set('created', $timestamp); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getOwner() { | ||||
|     return $this->get('user_id')->entity; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getOwnerId() { | ||||
|     return $this->get('user_id')->target_id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setOwnerId($uid) { | ||||
|     $this->set('user_id', $uid); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setOwner(UserInterface $account) { | ||||
|     $this->set('user_id', $account->id()); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | ||||
|     $fields = parent::baseFieldDefinitions($entity_type); | ||||
|  | ||||
|     // Add the published field. | ||||
|     $fields += static::publishedBaseFieldDefinitions($entity_type); | ||||
|  | ||||
|     $fields['user_id'] = BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Authored by')) | ||||
|       ->setDescription(t('The user ID of author of the Case Fee entity.')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSetting('target_type', 'user') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'hidden', | ||||
|         'type' => 'author', | ||||
|         'weight' => 0, | ||||
|       ]) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'entity_reference_autocomplete', | ||||
|         'weight' => 5, | ||||
|         'settings' => [ | ||||
|           'match_operator' => 'CONTAINS', | ||||
|           'size' => '60', | ||||
|           'autocomplete_type' => 'tags', | ||||
|           'placeholder' => '', | ||||
|         ], | ||||
|       ]) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE); | ||||
|  | ||||
|     $fields['name'] = BaseFieldDefinition::create('string') | ||||
|       ->setLabel(t('Name')) | ||||
|       ->setDescription(t('The name of the Case Fee entity.')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSettings([ | ||||
|         'max_length' => 50, | ||||
|         'text_processing' => 0, | ||||
|       ]) | ||||
|       ->setDefaultValue('') | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'above', | ||||
|         'type' => 'string', | ||||
|         'weight' => -4, | ||||
|       ]) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'string_textfield', | ||||
|         'weight' => -4, | ||||
|       ]) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE) | ||||
|       ->setRequired(TRUE); | ||||
|  | ||||
|     $fields['status']->setDescription(t('A boolean indicating whether the Case Fee is published.')) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE); | ||||
|  | ||||
|     $fields['created'] = BaseFieldDefinition::create('created') | ||||
|       ->setLabel(t('Created')) | ||||
|       ->setDescription(t('The time that the entity was created.')); | ||||
|  | ||||
|     $fields['changed'] = BaseFieldDefinition::create('changed') | ||||
|       ->setLabel(t('Changed')) | ||||
|       ->setDescription(t('The time that the entity was last edited.')); | ||||
|  | ||||
|     $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean') | ||||
|       ->setLabel(t('Revision translation affected')) | ||||
|       ->setDescription(t('Indicates if the last edit of a translation belongs to current revision.')) | ||||
|       ->setReadOnly(TRUE) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setTranslatable(TRUE); | ||||
|  | ||||
|     $fields['oc_case'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Case')) | ||||
|       ->setSetting('target_type', 'oc_case') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDefaultValueCallback('opencase_cases_default_case_id')  // defined in opencase_cases.module | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(TRUE); | ||||
|  | ||||
|     $fields['oc_fee_category'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Fee Category')) | ||||
|       ->setSetting('target_type', 'taxonomy_term') | ||||
|       ->setSetting('handler_settings', ['target_bundles' => ['oc_fee_category' => 'oc_fee_category']]) | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(FALSE); | ||||
|  | ||||
|     $fields['amount'] = BaseFieldDefinition::create('decimal') | ||||
|       ->setLabel(t('Amount')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSettings([ | ||||
|         'prefix' => '£', | ||||
|       ]) | ||||
|       ->setRequired(TRUE) | ||||
|       ->SetDisplayConfigurable("form", true) | ||||
|       ->SetDisplayConfigurable("view", true); | ||||
|  | ||||
|     return $fields; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										98
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeInterface.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,98 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityInterface; | ||||
| use Drupal\Core\Entity\RevisionLogInterface; | ||||
| use Drupal\Core\Entity\EntityChangedInterface; | ||||
| use Drupal\Core\Entity\EntityPublishedInterface; | ||||
| use Drupal\user\EntityOwnerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides an interface for defining Case Fee entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseFeeInterface extends ContentEntityInterface, RevisionLogInterface, EntityChangedInterface, EntityPublishedInterface, EntityOwnerInterface { | ||||
|  | ||||
|   /** | ||||
|    * Add get/set methods for your configuration properties here. | ||||
|    */ | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Fee name. | ||||
|    * | ||||
|    * @return string | ||||
|    *   Name of the Case Fee. | ||||
|    */ | ||||
|   public function getName(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Fee name. | ||||
|    * | ||||
|    * @param string $name | ||||
|    *   The Case Fee name. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    *   The called Case Fee entity. | ||||
|    */ | ||||
|   public function setName($name); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Fee creation timestamp. | ||||
|    * | ||||
|    * @return int | ||||
|    *   Creation timestamp of the Case Fee. | ||||
|    */ | ||||
|   public function getCreatedTime(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Fee creation timestamp. | ||||
|    * | ||||
|    * @param int $timestamp | ||||
|    *   The Case Fee creation timestamp. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    *   The called Case Fee entity. | ||||
|    */ | ||||
|   public function setCreatedTime($timestamp); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Fee revision creation timestamp. | ||||
|    * | ||||
|    * @return int | ||||
|    *   The UNIX timestamp of when this revision was created. | ||||
|    */ | ||||
|   public function getRevisionCreationTime(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Fee revision creation timestamp. | ||||
|    * | ||||
|    * @param int $timestamp | ||||
|    *   The UNIX timestamp of when this revision was created. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    *   The called Case Fee entity. | ||||
|    */ | ||||
|   public function setRevisionCreationTime($timestamp); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Fee revision author. | ||||
|    * | ||||
|    * @return \Drupal\user\UserInterface | ||||
|    *   The user entity for the revision author. | ||||
|    */ | ||||
|   public function getRevisionUser(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Fee revision author. | ||||
|    * | ||||
|    * @param int $uid | ||||
|    *   The user ID of the revision author. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    *   The called Case Fee entity. | ||||
|    */ | ||||
|   public function setRevisionUserId($uid); | ||||
|  | ||||
| } | ||||
							
								
								
									
										63
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeType.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeType.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityBundleBase; | ||||
|  | ||||
| /** | ||||
|  * Defines the Case Fee type entity. | ||||
|  * | ||||
|  * @ConfigEntityType( | ||||
|  *   id = "oc_case_fee_type", | ||||
|  *   label = @Translation("Case Fee type"), | ||||
|  *   handlers = { | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseFeeTypeListBuilder", | ||||
|  *     "form" = { | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseFeeTypeForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseFeeTypeForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseFeeTypeDeleteForm" | ||||
|  *     }, | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseFeeTypeHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *   }, | ||||
|  *   config_prefix = "oc_case_fee_type", | ||||
|  *   admin_permission = "administer site configuration", | ||||
|  *   bundle_of = "oc_case_fee", | ||||
|  *   entity_keys = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   config_export = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   links = { | ||||
|  *     "canonical" = "/opencase/oc_case_fee_type/{oc_case_fee_type}", | ||||
|  *     "add-form" = "/opencase/oc_case_fee_type/add", | ||||
|  *     "edit-form" = "/opencase/oc_case_fee_type/{oc_case_fee_type}/edit", | ||||
|  *     "delete-form" = "/opencase/oc_case_fee_type/{oc_case_fee_type}/delete", | ||||
|  *     "collection" = "/opencase/oc_case_fee_type" | ||||
|  *   } | ||||
|  * ) | ||||
|  */ | ||||
| class OCCaseFeeType extends ConfigEntityBundleBase implements OCCaseFeeTypeInterface { | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee type ID. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $id; | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee type label. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $label; | ||||
|  | ||||
| } | ||||
							
								
								
									
										13
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeTypeInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeTypeInterface.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides an interface for defining Case Fee type entities. | ||||
|  */ | ||||
| interface OCCaseFeeTypeInterface extends ConfigEntityInterface { | ||||
|  | ||||
|   // Add get/set methods for your configuration properties here. | ||||
| } | ||||
							
								
								
									
										23
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeViewsData.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								modules/opencase_cases/src/Entity/OCCaseFeeViewsData.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\views\EntityViewsData; | ||||
|  | ||||
| /** | ||||
|  * Provides Views data for Case Fee entities. | ||||
|  */ | ||||
| class OCCaseFeeViewsData extends EntityViewsData { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getViewsData() { | ||||
|     $data = parent::getViewsData(); | ||||
|  | ||||
|     // Additional information for Views integration, such as table joins, can be | ||||
|     // put here. | ||||
|     return $data; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Entity; | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
| 
 | ||||
| use Drupal\Core\Entity\ContentEntityInterface; | ||||
| use Drupal\Core\Entity\RevisionLogInterface; | ||||
| @ -10,7 +10,7 @@ use Drupal\user\EntityOwnerInterface; | ||||
| /** | ||||
|  * Provides an interface for defining Case entities. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, EntityChangedInterface, EntityOwnerInterface { | ||||
| 
 | ||||
| @ -30,7 +30,7 @@ interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, | ||||
|    * @param string $name | ||||
|    *   The Case name. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The called Case entity. | ||||
|    */ | ||||
|   public function setName($name); | ||||
| @ -49,7 +49,7 @@ interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, | ||||
|    * @param int $timestamp | ||||
|    *   The Case creation timestamp. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The called Case entity. | ||||
|    */ | ||||
|   public function setCreatedTime($timestamp); | ||||
| @ -70,7 +70,7 @@ interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, | ||||
|    * @param bool $published | ||||
|    *   TRUE to set this Case to published, FALSE to set it to unpublished. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The called Case entity. | ||||
|    */ | ||||
|   public function setPublished($published); | ||||
| @ -89,7 +89,7 @@ interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, | ||||
|    * @param int $timestamp | ||||
|    *   The UNIX timestamp of when this revision was created. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The called Case entity. | ||||
|    */ | ||||
|   public function setRevisionCreationTime($timestamp); | ||||
| @ -108,7 +108,7 @@ interface OCCaseInterface extends ContentEntityInterface, RevisionLogInterface, | ||||
|    * @param int $uid | ||||
|    *   The user ID of the revision author. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The called Case entity. | ||||
|    */ | ||||
|   public function setRevisionUserId($uid); | ||||
							
								
								
									
										314
									
								
								modules/opencase_cases/src/Entity/OCCaseProvision.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										314
									
								
								modules/opencase_cases/src/Entity/OCCaseProvision.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,314 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| use Drupal\Core\Field\BaseFieldDefinition; | ||||
| use Drupal\Core\Entity\EditorialContentEntityBase; | ||||
| use Drupal\Core\Entity\RevisionableInterface; | ||||
| use Drupal\Core\Entity\EntityChangedTrait; | ||||
| use Drupal\Core\Entity\EntityPublishedTrait; | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\user\UserInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the Case Provision entity. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  * | ||||
|  * @ContentEntityType( | ||||
|  *   id = "oc_case_provision", | ||||
|  *   label = @Translation("Case Provision"), | ||||
|  *   bundle_label = @Translation("Case Provision type"), | ||||
|  *   handlers = { | ||||
|  *     "storage" = "Drupal\opencase_cases\OCCaseProvisionStorage", | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseProvisionListBuilder", | ||||
|  *     "views_data" = "Drupal\opencase_cases\Entity\OCCaseProvisionViewsData", | ||||
|  *     "translation" = "Drupal\opencase_cases\OCCaseProvisionTranslationHandler", | ||||
|  * | ||||
|  *     "form" = { | ||||
|  *       "default" = "Drupal\opencase_cases\Form\OCCaseProvisionForm", | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseProvisionForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseProvisionForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseProvisionDeleteForm", | ||||
|  *     }, | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseProvisionHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *     "access" = "Drupal\opencase_cases\OCCaseProvisionAccessControlHandler", | ||||
|  *   }, | ||||
|  *   base_table = "oc_case_provision", | ||||
|  *   data_table = "oc_case_provision_field_data", | ||||
|  *   revision_table = "oc_case_provision_revision", | ||||
|  *   revision_data_table = "oc_case_provision_field_revision", | ||||
|  *   translatable = TRUE, | ||||
|  *   permission_granularity = "bundle", | ||||
|  *   admin_permission = "administer case provision entities", | ||||
|  *   entity_keys = { | ||||
|  *     "id" = "id", | ||||
|  *     "revision" = "vid", | ||||
|  *     "bundle" = "type", | ||||
|  *     "label" = "name", | ||||
|  *     "uuid" = "uuid", | ||||
|  *     "uid" = "user_id", | ||||
|  *     "langcode" = "langcode", | ||||
|  *     "published" = "status", | ||||
|  *   }, | ||||
|  *   revision_metadata_keys = { | ||||
|  *     "revision_user" = "revision_user", | ||||
|  *     "revision_created" = "revision_created", | ||||
|  *     "revision_log_message" = "revision_log", | ||||
|  *   }, | ||||
|  *   links = { | ||||
|  *     "canonical" = "/opencase/oc_case_provision/{oc_case_provision}", | ||||
|  *     "add-page" = "/opencase/oc_case_provision/add", | ||||
|  *     "add-form" = "/opencase/oc_case_provision/add/{oc_case_provision_type}", | ||||
|  *     "edit-form" = "/opencase/oc_case_provision/{oc_case_provision}/edit", | ||||
|  *     "delete-form" = "/opencase/oc_case_provision/{oc_case_provision}/delete", | ||||
|  *     "version-history" = "/opencase/oc_case_provision/{oc_case_provision}/revisions", | ||||
|  *     "revision" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/view", | ||||
|  *     "revision_revert" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/revert", | ||||
|  *     "revision_delete" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/delete", | ||||
|  *     "translation_revert" = "/opencase/oc_case_provision/{oc_case_provision}/revisions/{oc_case_provision_revision}/revert/{langcode}", | ||||
|  *     "collection" = "/opencase/oc_case_provision", | ||||
|  *   }, | ||||
|  *   bundle_entity_type = "oc_case_provision_type", | ||||
|  *   field_ui_base_route = "entity.oc_case_provision_type.edit_form" | ||||
|  * ) | ||||
|  */ | ||||
| class OCCaseProvision extends EditorialContentEntityBase implements OCCaseProvisionInterface { | ||||
|  | ||||
|   use EntityChangedTrait; | ||||
|   use EntityPublishedTrait; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function preCreate(EntityStorageInterface $storage_controller, array &$values) { | ||||
|     parent::preCreate($storage_controller, $values); | ||||
|     $values += [ | ||||
|       'user_id' => \Drupal::currentUser()->id(), | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function urlRouteParameters($rel) { | ||||
|     $uri_route_parameters = parent::urlRouteParameters($rel); | ||||
|  | ||||
|     if ($rel === 'revision_revert' && $this instanceof RevisionableInterface) { | ||||
|       $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); | ||||
|     } | ||||
|     elseif ($rel === 'revision_delete' && $this instanceof RevisionableInterface) { | ||||
|       $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); | ||||
|     } | ||||
|  | ||||
|     return $uri_route_parameters; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function preSave(EntityStorageInterface $storage) { | ||||
|     parent::preSave($storage); | ||||
|  | ||||
|     foreach (array_keys($this->getTranslationLanguages()) as $langcode) { | ||||
|       $translation = $this->getTranslation($langcode); | ||||
|  | ||||
|       // If no owner has been set explicitly, make the anonymous user the owner. | ||||
|       if (!$translation->getOwner()) { | ||||
|         $translation->setOwnerId(0); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     // If no revision author has been set explicitly, | ||||
|     // make the oc_case_provision owner the revision author. | ||||
|     if (!$this->getRevisionUser()) { | ||||
|       $this->setRevisionUserId($this->getOwnerId()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getName() { | ||||
|     return $this->get('name')->value; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setName($name) { | ||||
|     $this->set('name', $name); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCreatedTime() { | ||||
|     return $this->get('created')->value; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setCreatedTime($timestamp) { | ||||
|     $this->set('created', $timestamp); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getOwner() { | ||||
|     return $this->get('user_id')->entity; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getOwnerId() { | ||||
|     return $this->get('user_id')->target_id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setOwnerId($uid) { | ||||
|     $this->set('user_id', $uid); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function setOwner(UserInterface $account) { | ||||
|     $this->set('user_id', $account->id()); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | ||||
|     $fields = parent::baseFieldDefinitions($entity_type); | ||||
|  | ||||
|     // Add the published field. | ||||
|     $fields += static::publishedBaseFieldDefinitions($entity_type); | ||||
|  | ||||
|     $fields['user_id'] = BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Authored by')) | ||||
|       ->setDescription(t('The user ID of author of the Case Provision entity.')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSetting('target_type', 'user') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'hidden', | ||||
|         'type' => 'author', | ||||
|         'weight' => 0, | ||||
|       ]) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'entity_reference_autocomplete', | ||||
|         'weight' => 5, | ||||
|         'settings' => [ | ||||
|           'match_operator' => 'CONTAINS', | ||||
|           'size' => '60', | ||||
|           'autocomplete_type' => 'tags', | ||||
|           'placeholder' => '', | ||||
|         ], | ||||
|       ]) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE); | ||||
|  | ||||
|     $fields['name'] = BaseFieldDefinition::create('string') | ||||
|       ->setLabel(t('Name')) | ||||
|       ->setDescription(t('The name of the Case Provision entity.')) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setSettings([ | ||||
|         'max_length' => 50, | ||||
|         'text_processing' => 0, | ||||
|       ]) | ||||
|       ->setDefaultValue('') | ||||
|       ->setDisplayOptions('view', [ | ||||
|         'label' => 'above', | ||||
|         'type' => 'string', | ||||
|         'weight' => -4, | ||||
|       ]) | ||||
|       ->setDisplayOptions('form', [ | ||||
|         'type' => 'string_textfield', | ||||
|         'weight' => -4, | ||||
|       ]) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE) | ||||
|       ->setRequired(TRUE); | ||||
|  | ||||
|  | ||||
|       $fields['status'] = BaseFieldDefinition::create('boolean') | ||||
|       ->setLabel(t('Visible')) | ||||
|       ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.') | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDefaultValue(TRUE); | ||||
|  | ||||
|  | ||||
|     $fields['created'] = BaseFieldDefinition::create('created') | ||||
|       ->setLabel(t('Created')) | ||||
|       ->setDescription(t('The time that the entity was created.')); | ||||
|  | ||||
|     $fields['changed'] = BaseFieldDefinition::create('changed') | ||||
|       ->setLabel(t('Changed')) | ||||
|       ->setDescription(t('The time that the entity was last edited.')); | ||||
|  | ||||
|     $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean') | ||||
|       ->setLabel(t('Revision translation affected')) | ||||
|       ->setDescription(t('Indicates if the last edit of a translation belongs to current revision.')) | ||||
|       ->setReadOnly(TRUE) | ||||
|       ->setRevisionable(TRUE) | ||||
|       ->setTranslatable(TRUE); | ||||
|  | ||||
|     $fields['oc_case'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Case')) | ||||
|       ->setSetting('target_type', 'oc_case') | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDefaultValueCallback('opencase_cases_default_case_id')  // defined in opencase_cases.module | ||||
|       ->setDisplayConfigurable('form', TRUE) | ||||
|       ->setDisplayConfigurable('view', TRUE) | ||||
|       ->setRequired(TRUE); | ||||
|  | ||||
|     $fields['oc_provider'] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference') | ||||
|       ->setLabel(t('Provider')) | ||||
|       ->setSetting('target_type', 'oc_actor') // TODO: this should eventually point to a Provider rather than an Actor | ||||
|       ->setSetting('handler', 'views') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setSetting('handler_settings', [ | ||||
|         'view' => [ | ||||
|           'view_name' => 'case_providers', | ||||
|           'display_name' => 'entity_reference_1', | ||||
|           'arguments' => [], | ||||
|         ] | ||||
|       ]) | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(TRUE); | ||||
|  | ||||
|     $fields['oc_case_provider_role'] = \Drupal\Core\Field\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']]) | ||||
|       ->setSetting('handler', 'default') | ||||
|       ->setTranslatable(TRUE) | ||||
|       ->setCardinality(1) | ||||
|       ->setDisplayConfigurable("view", true) | ||||
|       ->setDisplayConfigurable("form", true) | ||||
|       ->setRequired(FALSE); | ||||
|     return $fields; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,98 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityInterface; | ||||
| use Drupal\Core\Entity\RevisionLogInterface; | ||||
| use Drupal\Core\Entity\EntityChangedInterface; | ||||
| use Drupal\Core\Entity\EntityPublishedInterface; | ||||
| use Drupal\user\EntityOwnerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides an interface for defining Case Provision entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseProvisionInterface extends ContentEntityInterface, RevisionLogInterface, EntityChangedInterface, EntityPublishedInterface, EntityOwnerInterface { | ||||
|  | ||||
|   /** | ||||
|    * Add get/set methods for your configuration properties here. | ||||
|    */ | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Provision name. | ||||
|    * | ||||
|    * @return string | ||||
|    *   Name of the Case Provision. | ||||
|    */ | ||||
|   public function getName(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Provision name. | ||||
|    * | ||||
|    * @param string $name | ||||
|    *   The Case Provision name. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    *   The called Case Provision entity. | ||||
|    */ | ||||
|   public function setName($name); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Provision creation timestamp. | ||||
|    * | ||||
|    * @return int | ||||
|    *   Creation timestamp of the Case Provision. | ||||
|    */ | ||||
|   public function getCreatedTime(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Provision creation timestamp. | ||||
|    * | ||||
|    * @param int $timestamp | ||||
|    *   The Case Provision creation timestamp. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    *   The called Case Provision entity. | ||||
|    */ | ||||
|   public function setCreatedTime($timestamp); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Provision revision creation timestamp. | ||||
|    * | ||||
|    * @return int | ||||
|    *   The UNIX timestamp of when this revision was created. | ||||
|    */ | ||||
|   public function getRevisionCreationTime(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Provision revision creation timestamp. | ||||
|    * | ||||
|    * @param int $timestamp | ||||
|    *   The UNIX timestamp of when this revision was created. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    *   The called Case Provision entity. | ||||
|    */ | ||||
|   public function setRevisionCreationTime($timestamp); | ||||
|  | ||||
|   /** | ||||
|    * Gets the Case Provision revision author. | ||||
|    * | ||||
|    * @return \Drupal\user\UserInterface | ||||
|    *   The user entity for the revision author. | ||||
|    */ | ||||
|   public function getRevisionUser(); | ||||
|  | ||||
|   /** | ||||
|    * Sets the Case Provision revision author. | ||||
|    * | ||||
|    * @param int $uid | ||||
|    *   The user ID of the revision author. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    *   The called Case Provision entity. | ||||
|    */ | ||||
|   public function setRevisionUserId($uid); | ||||
|  | ||||
| } | ||||
							
								
								
									
										63
									
								
								modules/opencase_cases/src/Entity/OCCaseProvisionType.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								modules/opencase_cases/src/Entity/OCCaseProvisionType.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityBundleBase; | ||||
|  | ||||
| /** | ||||
|  * Defines the Case Provision type entity. | ||||
|  * | ||||
|  * @ConfigEntityType( | ||||
|  *   id = "oc_case_provision_type", | ||||
|  *   label = @Translation("Case Provision type"), | ||||
|  *   handlers = { | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseProvisionTypeListBuilder", | ||||
|  *     "form" = { | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseProvisionTypeDeleteForm" | ||||
|  *     }, | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseProvisionTypeHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *   }, | ||||
|  *   config_prefix = "oc_case_provision_type", | ||||
|  *   admin_permission = "administer site configuration", | ||||
|  *   bundle_of = "oc_case_provision", | ||||
|  *   entity_keys = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   config_export = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   links = { | ||||
|  *     "canonical" = "/opencase/oc_case_provision_type/{oc_case_provision_type}", | ||||
|  *     "add-form" = "/opencase/oc_case_provision_type/add", | ||||
|  *     "edit-form" = "/opencase/oc_case_provision_type/{oc_case_provision_type}/edit", | ||||
|  *     "delete-form" = "/opencase/oc_case_provision_type/{oc_case_provision_type}/delete", | ||||
|  *     "collection" = "/opencase/oc_case_provision_type" | ||||
|  *   } | ||||
|  * ) | ||||
|  */ | ||||
| class OCCaseProvisionType extends ConfigEntityBundleBase implements OCCaseProvisionTypeInterface { | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision type ID. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $id; | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision type label. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $label; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,13 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides an interface for defining Case Provision type entities. | ||||
|  */ | ||||
| interface OCCaseProvisionTypeInterface extends ConfigEntityInterface { | ||||
|  | ||||
|   // Add get/set methods for your configuration properties here. | ||||
| } | ||||
| @ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
|  | ||||
| use Drupal\views\EntityViewsData; | ||||
|  | ||||
| /** | ||||
|  * Provides Views data for Case Provision entities. | ||||
|  */ | ||||
| class OCCaseProvisionViewsData extends EntityViewsData { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getViewsData() { | ||||
|     $data = parent::getViewsData(); | ||||
|  | ||||
|     // Additional information for Views integration, such as table joins, can be | ||||
|     // put here. | ||||
|     return $data; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Entity; | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
| 
 | ||||
| use Drupal\Core\Config\Entity\ConfigEntityBundleBase; | ||||
| 
 | ||||
| @ -11,26 +11,31 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase; | ||||
|  *   id = "oc_case_type", | ||||
|  *   label = @Translation("Case type"), | ||||
|  *   handlers = { | ||||
|  *     "access" = "Drupal\opencase_entities\OCCaseTypeAccessControlHandler", | ||||
|  *     "access" = "Drupal\opencase_cases\OCCaseTypeAccessControlHandler", | ||||
|  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_entities\OCCaseTypeListBuilder", | ||||
|  *     "list_builder" = "Drupal\opencase_cases\OCCaseTypeListBuilder", | ||||
|  *     "form" = { | ||||
|  *       "add" = "Drupal\opencase_entities\Form\OCCaseTypeForm", | ||||
|  *       "edit" = "Drupal\opencase_entities\Form\OCCaseTypeForm", | ||||
|  *       "delete" = "Drupal\opencase_entities\Form\OCCaseTypeDeleteForm" | ||||
|  *       "add" = "Drupal\opencase_cases\Form\OCCaseTypeForm", | ||||
|  *       "edit" = "Drupal\opencase_cases\Form\OCCaseTypeForm", | ||||
|  *       "delete" = "Drupal\opencase_cases\Form\OCCaseTypeDeleteForm" | ||||
|  *     }, | ||||
|  *     "route_provider" = { | ||||
|  *       "html" = "Drupal\opencase_entities\OCCaseTypeHtmlRouteProvider", | ||||
|  *       "html" = "Drupal\opencase_cases\OCCaseTypeHtmlRouteProvider", | ||||
|  *     }, | ||||
|  *   }, | ||||
|  *   config_prefix = "oc_case_type", | ||||
|  *   admin_permission = "administer opencase entity bundles", | ||||
|  *   admin_permission = "administer case bundles", | ||||
|  *   bundle_of = "oc_case", | ||||
|  *   entity_keys = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   config_export = { | ||||
|  *     "id" = "id", | ||||
|  *     "label" = "label", | ||||
|  *     "uuid" = "uuid" | ||||
|  *   }, | ||||
|  *   links = { | ||||
|  *     "canonical" = "/admin/opencase/oc_case_type/{oc_case_type}", | ||||
|  *     "add-form" = "/admin/opencase/oc_case_type/add", | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Entity; | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
| 
 | ||||
| use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||||
| 
 | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Entity; | ||||
| namespace Drupal\opencase_cases\Entity; | ||||
| 
 | ||||
| use Drupal\views\EntityViewsData; | ||||
| 
 | ||||
| @ -1,13 +1,13 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Entity\ContentEntityDeleteForm; | ||||
| 
 | ||||
| /** | ||||
|  * Provides a form for deleting Case entities. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseDeleteForm extends ContentEntityDeleteForm { | ||||
| 
 | ||||
							
								
								
									
										15
									
								
								modules/opencase_cases/src/Form/OCCaseFeeDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								modules/opencase_cases/src/Form/OCCaseFeeDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityDeleteForm; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for deleting Case Fee entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeDeleteForm extends ContentEntityDeleteForm { | ||||
|  | ||||
|  | ||||
| } | ||||
							
								
								
									
										78
									
								
								modules/opencase_cases/src/Form/OCCaseFeeForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								modules/opencase_cases/src/Form/OCCaseFeeForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,78 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Form controller for Case Fee edit forms. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeForm extends ContentEntityForm { | ||||
|  | ||||
|   /** | ||||
|    * The current user account. | ||||
|    * | ||||
|    * @var \Drupal\Core\Session\AccountProxyInterface | ||||
|    */ | ||||
|   protected $account; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     // Instantiates this form class. | ||||
|     $instance = parent::create($container); | ||||
|     $instance->account = $container->get('current_user'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state) { | ||||
|     /* @var \Drupal\opencase_cases\Entity\OCCaseFee $entity */ | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     if (!$this->entity->isNew()) { | ||||
|       $form['new_revision'] = [ | ||||
|         '#type' => 'checkbox', | ||||
|         '#title' => $this->t('Create new revision'), | ||||
|         '#default_value' => FALSE, | ||||
|         '#weight' => 10, | ||||
|       ]; | ||||
|     } | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function save(array $form, FormStateInterface $form_state) { | ||||
|     $entity = $this->entity; | ||||
|     $entity->setNewRevision(); | ||||
|     $entity->setRevisionCreationTime(REQUEST_TIME); | ||||
|     $entity->setRevisionUserId(\Drupal::currentUser()->id()); | ||||
|  | ||||
|     $status = parent::save($form, $form_state); | ||||
|  | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         $this->messenger()->addMessage($this->t('Created the %label Case Fee.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|         break; | ||||
|  | ||||
|       default: | ||||
|         $this->messenger()->addMessage($this->t('Saved the %label Case Fee.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|     } | ||||
|     $form_state->setRedirect('entity.oc_case_fee.canonical', ['oc_case_fee' => $entity->id()]); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										108
									
								
								modules/opencase_cases/src/Form/OCCaseFeeRevisionDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								modules/opencase_cases/src/Form/OCCaseFeeRevisionDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,108 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\ConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for deleting a Case Fee revision. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeRevisionDeleteForm extends ConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee storage. | ||||
|    * | ||||
|    * @var \Drupal\Core\Entity\EntityStorageInterface | ||||
|    */ | ||||
|   protected $oCCaseFeeStorage; | ||||
|  | ||||
|   /** | ||||
|    * The database connection. | ||||
|    * | ||||
|    * @var \Drupal\Core\Database\Connection | ||||
|    */ | ||||
|   protected $connection; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->oCCaseFeeStorage = $container->get('entity_type.manager')->getStorage('oc_case_fee'); | ||||
|     $instance->connection = $container->get('database'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_fee_revision_delete_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to delete the revision from %revision-date?', [ | ||||
|       '%revision-date' => format_date($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_fee.version_history', ['oc_case_fee' => $this->revision->id()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Delete'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL) { | ||||
|     $this->revision = $this->OCCaseFeeStorage->loadRevision($oc_case_fee_revision); | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     $this->OCCaseFeeStorage->deleteRevision($this->revision->getRevisionId()); | ||||
|  | ||||
|     $this->logger('content')->notice('Case Fee: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     $this->messenger()->addMessage(t('Revision from %revision-date of Case Fee %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case_fee.canonical', | ||||
|        ['oc_case_fee' => $this->revision->id()] | ||||
|     ); | ||||
|     if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {oc_case_fee_field_revision} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) { | ||||
|       $form_state->setRedirect( | ||||
|         'entity.oc_case_fee.version_history', | ||||
|          ['oc_case_fee' => $this->revision->id()] | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										137
									
								
								modules/opencase_cases/src/Form/OCCaseFeeRevisionRevertForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								modules/opencase_cases/src/Form/OCCaseFeeRevisionRevertForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,137 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\ConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFeeInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for reverting a Case Fee revision. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeRevisionRevertForm extends ConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
|  | ||||
|   /** | ||||
|    * The Case Fee storage. | ||||
|    * | ||||
|    * @var \Drupal\Core\Entity\EntityStorageInterface | ||||
|    */ | ||||
|   protected $oCCaseFeeStorage; | ||||
|  | ||||
|   /** | ||||
|    * The date formatter service. | ||||
|    * | ||||
|    * @var \Drupal\Core\Datetime\DateFormatterInterface | ||||
|    */ | ||||
|   protected $dateFormatter; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->oCCaseFeeStorage = $container->get('entity_type.manager')->getStorage('oc_case_fee'); | ||||
|     $instance->dateFormatter = $container->get('date.formatter'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_fee_revision_revert_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to revert to the revision from %revision-date?', [ | ||||
|       '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_fee.version_history', ['oc_case_fee' => $this->revision->id()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Revert'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getDescription() { | ||||
|     return ''; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL) { | ||||
|     $this->revision = $this->OCCaseFeeStorage->loadRevision($oc_case_fee_revision); | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     // The revision timestamp will be updated when the revision is saved. Keep | ||||
|     // the original one for the confirmation message. | ||||
|     $original_revision_timestamp = $this->revision->getRevisionCreationTime(); | ||||
|  | ||||
|     $this->revision = $this->prepareRevertedRevision($this->revision, $form_state); | ||||
|     $this->revision->revision_log = $this->t('Copy of the revision from %date.', [ | ||||
|       '%date' => $this->dateFormatter->format($original_revision_timestamp), | ||||
|     ]); | ||||
|     $this->revision->save(); | ||||
|  | ||||
|     $this->logger('content')->notice('Case Fee: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     $this->messenger()->addMessage(t('Case Fee %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case_fee.version_history', | ||||
|       ['oc_case_fee' => $this->revision->id()] | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Prepares a revision to be reverted. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $revision | ||||
|    *   The revision to be reverted. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseFeeInterface | ||||
|    *   The prepared revision ready to be stored. | ||||
|    */ | ||||
|   protected function prepareRevertedRevision(OCCaseFeeInterface $revision, FormStateInterface $form_state) { | ||||
|     $revision->setNewRevision(); | ||||
|     $revision->isDefaultRevision(TRUE); | ||||
|     $revision->setRevisionCreationTime(REQUEST_TIME); | ||||
|  | ||||
|     return $revision; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFeeInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for reverting a Case Fee revision for a single trans. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeRevisionRevertTranslationForm extends OCCaseFeeRevisionRevertForm { | ||||
|  | ||||
|   /** | ||||
|    * The language to be reverted. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $langcode; | ||||
|  | ||||
|   /** | ||||
|    * The language manager. | ||||
|    * | ||||
|    * @var \Drupal\Core\Language\LanguageManagerInterface | ||||
|    */ | ||||
|   protected $languageManager; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->languageManager = $container->get('language_manager'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_fee_revision_revert_translation_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to revert @language translation to the revision from %revision-date?', [ | ||||
|       '@language' => $this->languageManager->getLanguageName($this->langcode), | ||||
|       '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_fee_revision = NULL, $langcode = NULL) { | ||||
|     $this->langcode = $langcode; | ||||
|     $form = parent::buildForm($form, $form_state, $oc_case_fee_revision); | ||||
|  | ||||
|     $form['revert_untranslated_fields'] = [ | ||||
|       '#type' => 'checkbox', | ||||
|       '#title' => $this->t('Revert content shared among translations'), | ||||
|       '#default_value' => FALSE, | ||||
|     ]; | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function prepareRevertedRevision(OCCaseFeeInterface $revision, FormStateInterface $form_state) { | ||||
|     $revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields'); | ||||
|  | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface $default_revision */ | ||||
|     $latest_revision = $this->OCCaseFeeStorage->load($revision->id()); | ||||
|     $latest_revision_translation = $latest_revision->getTranslation($this->langcode); | ||||
|  | ||||
|     $revision_translation = $revision->getTranslation($this->langcode); | ||||
|  | ||||
|     foreach ($latest_revision_translation->getFieldDefinitions() as $field_name => $definition) { | ||||
|       if ($definition->isTranslatable() || $revert_untranslated_fields) { | ||||
|         $latest_revision_translation->set($field_name, $revision_translation->get($field_name)->getValue()); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     $latest_revision_translation->setNewRevision(); | ||||
|     $latest_revision_translation->isDefaultRevision(TRUE); | ||||
|     $revision->setRevisionCreationTime(REQUEST_TIME); | ||||
|  | ||||
|     return $latest_revision_translation; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										53
									
								
								modules/opencase_cases/src/Form/OCCaseFeeSettingsForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								modules/opencase_cases/src/Form/OCCaseFeeSettingsForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\FormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseFeeSettingsForm. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeSettingsForm extends FormBase { | ||||
|  | ||||
|   /** | ||||
|    * Returns a unique string identifying the form. | ||||
|    * | ||||
|    * @return string | ||||
|    *   The unique string identifying the form. | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'occasefee_settings'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Form submission handler. | ||||
|    * | ||||
|    * @param array $form | ||||
|    *   An associative array containing the structure of the form. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     // Empty implementation of the abstract submit class. | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Defines the settings form for Case Fee entities. | ||||
|    * | ||||
|    * @param array $form | ||||
|    *   An associative array containing the structure of the form. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    * | ||||
|    * @return array | ||||
|    *   Form definition array. | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state) { | ||||
|     $form['occasefee_settings']['#markup'] = 'Settings form for Case Fee entities. Manage field settings here.'; | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										51
									
								
								modules/opencase_cases/src/Form/OCCaseFeeTypeDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								modules/opencase_cases/src/Form/OCCaseFeeTypeDeleteForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,51 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
|  | ||||
| /** | ||||
|  * Builds the form to delete Case Fee type entities. | ||||
|  */ | ||||
| class OCCaseFeeTypeDeleteForm extends EntityConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_fee_type.collection'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Delete'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     $this->entity->delete(); | ||||
|  | ||||
|     $this->messenger()->addMessage( | ||||
|       $this->t('content @type: deleted @label.', [ | ||||
|         '@type' => $this->entity->bundle(), | ||||
|         '@label' => $this->entity->label(), | ||||
|       ]) | ||||
|     ); | ||||
|  | ||||
|     $form_state->setRedirectUrl($this->getCancelUrl()); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										65
									
								
								modules/opencase_cases/src/Form/OCCaseFeeTypeForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								modules/opencase_cases/src/Form/OCCaseFeeTypeForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseFeeTypeForm. | ||||
|  */ | ||||
| class OCCaseFeeTypeForm extends EntityForm { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function form(array $form, FormStateInterface $form_state) { | ||||
|     $form = parent::form($form, $form_state); | ||||
|  | ||||
|     $oc_case_fee_type = $this->entity; | ||||
|     $form['label'] = [ | ||||
|       '#type' => 'textfield', | ||||
|       '#title' => $this->t('Label'), | ||||
|       '#maxlength' => 255, | ||||
|       '#default_value' => $oc_case_fee_type->label(), | ||||
|       '#description' => $this->t("Label for the Case Fee type."), | ||||
|       '#required' => TRUE, | ||||
|     ]; | ||||
|  | ||||
|     $form['id'] = [ | ||||
|       '#type' => 'machine_name', | ||||
|       '#default_value' => $oc_case_fee_type->id(), | ||||
|       '#machine_name' => [ | ||||
|         'exists' => '\Drupal\opencase_cases\Entity\OCCaseFeeType::load', | ||||
|       ], | ||||
|       '#disabled' => !$oc_case_fee_type->isNew(), | ||||
|     ]; | ||||
|  | ||||
|     /* You will need additional form elements for your custom properties. */ | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function save(array $form, FormStateInterface $form_state) { | ||||
|     $oc_case_fee_type = $this->entity; | ||||
|     $status = $oc_case_fee_type->save(); | ||||
|  | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         $this->messenger()->addMessage($this->t('Created the %label Case Fee type.', [ | ||||
|           '%label' => $oc_case_fee_type->label(), | ||||
|         ])); | ||||
|         break; | ||||
|  | ||||
|       default: | ||||
|         $this->messenger()->addMessage($this->t('Saved the %label Case Fee type.', [ | ||||
|           '%label' => $oc_case_fee_type->label(), | ||||
|         ])); | ||||
|     } | ||||
|     $form_state->setRedirectUrl($oc_case_fee_type->toUrl('collection')); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										70
									
								
								modules/opencase_cases/src/Form/OCCaseForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								modules/opencase_cases/src/Form/OCCaseForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
|  | ||||
| /** | ||||
|  * Form controller for Case edit forms. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseForm extends ContentEntityForm { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state) { | ||||
|     /* @var $entity \Drupal\opencase_cases\Entity\OCCase */ | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     if (!$this->entity->isNew()) { | ||||
|       $form['new_revision'] = [ | ||||
|         '#type' => 'checkbox', | ||||
|         '#title' => $this->t('Create new revision'), | ||||
|         '#default_value' => FALSE, | ||||
|         '#weight' => 10, | ||||
|       ]; | ||||
|     } | ||||
|  | ||||
|     $entity = $this->entity; | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function save(array $form, FormStateInterface $form_state) { | ||||
|     $entity = $this->entity; | ||||
|     $entity->setNewRevision(); | ||||
|     $entity->setRevisionCreationTime(REQUEST_TIME); | ||||
|     $entity->setRevisionUserId(\Drupal::currentUser()->id()); | ||||
|  | ||||
|     $status = parent::save($form, $form_state); | ||||
|  | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         \Drupal::messenger()->addMessage($this->t('Created the %label Case.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|         break; | ||||
|  | ||||
|       default: | ||||
|         \Drupal::messenger()->addMessage($this->t('Saved the %label Case.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|     } | ||||
|     // If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied". | ||||
|     if (!$form_state->getValue('status')['value'] && !\Drupal::currentUser()->hasPermission('view unpublished case entities')) { | ||||
|       \Drupal::messenger()->addMessage($this->t('The record for "%label" is now unpublished & hidden from you.', [ | ||||
|         '%label' => $entity->label(), | ||||
|       ])); | ||||
|       $form_state->setRedirect('<front>'); | ||||
|     } else { | ||||
|       $form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $entity->id()]); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityDeleteForm; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for deleting Case Provision entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionDeleteForm extends ContentEntityDeleteForm { | ||||
|  | ||||
|  | ||||
| } | ||||
							
								
								
									
										78
									
								
								modules/opencase_cases/src/Form/OCCaseProvisionForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								modules/opencase_cases/src/Form/OCCaseProvisionForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,78 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Form controller for Case Provision edit forms. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionForm extends ContentEntityForm { | ||||
|  | ||||
|   /** | ||||
|    * The current user account. | ||||
|    * | ||||
|    * @var \Drupal\Core\Session\AccountProxyInterface | ||||
|    */ | ||||
|   protected $account; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     // Instantiates this form class. | ||||
|     $instance = parent::create($container); | ||||
|     $instance->account = $container->get('current_user'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state) { | ||||
|     /* @var \Drupal\opencase_cases\Entity\OCCaseProvision $entity */ | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     if (!$this->entity->isNew()) { | ||||
|       $form['new_revision'] = [ | ||||
|         '#type' => 'checkbox', | ||||
|         '#title' => $this->t('Create new revision'), | ||||
|         '#default_value' => FALSE, | ||||
|         '#weight' => 10, | ||||
|       ]; | ||||
|     } | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function save(array $form, FormStateInterface $form_state) { | ||||
|     $entity = $this->entity; | ||||
|     $entity->setNewRevision(); | ||||
|     $entity->setRevisionCreationTime(REQUEST_TIME); | ||||
|     $entity->setRevisionUserId(\Drupal::currentUser()->id()); | ||||
|  | ||||
|     $status = parent::save($form, $form_state); | ||||
|  | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         $this->messenger()->addMessage($this->t('Created the %label Case Provision.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|         break; | ||||
|  | ||||
|       default: | ||||
|         $this->messenger()->addMessage($this->t('Saved the %label Case Provision.', [ | ||||
|           '%label' => $entity->label(), | ||||
|         ])); | ||||
|     } | ||||
|     $form_state->setRedirect('entity.oc_case_provision.canonical', ['oc_case_provision' => $entity->id()]); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,108 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\ConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for deleting a Case Provision revision. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionRevisionDeleteForm extends ConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision storage. | ||||
|    * | ||||
|    * @var \Drupal\Core\Entity\EntityStorageInterface | ||||
|    */ | ||||
|   protected $oCCaseProvisionStorage; | ||||
|  | ||||
|   /** | ||||
|    * The database connection. | ||||
|    * | ||||
|    * @var \Drupal\Core\Database\Connection | ||||
|    */ | ||||
|   protected $connection; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->oCCaseProvisionStorage = $container->get('entity_type.manager')->getStorage('oc_case_provision'); | ||||
|     $instance->connection = $container->get('database'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_provision_revision_delete_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to delete the revision from %revision-date?', [ | ||||
|       '%revision-date' => format_date($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_provision.version_history', ['oc_case_provision' => $this->revision->id()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Delete'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL) { | ||||
|     $this->revision = $this->OCCaseProvisionStorage->loadRevision($oc_case_provision_revision); | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     $this->OCCaseProvisionStorage->deleteRevision($this->revision->getRevisionId()); | ||||
|  | ||||
|     $this->logger('content')->notice('Case Provision: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     $this->messenger()->addMessage(t('Revision from %revision-date of Case Provision %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case_provision.canonical', | ||||
|        ['oc_case_provision' => $this->revision->id()] | ||||
|     ); | ||||
|     if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {oc_case_provision_field_revision} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) { | ||||
|       $form_state->setRedirect( | ||||
|         'entity.oc_case_provision.version_history', | ||||
|          ['oc_case_provision' => $this->revision->id()] | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,137 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\ConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvisionInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for reverting a Case Provision revision. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionRevisionRevertForm extends ConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
|  | ||||
|   /** | ||||
|    * The Case Provision storage. | ||||
|    * | ||||
|    * @var \Drupal\Core\Entity\EntityStorageInterface | ||||
|    */ | ||||
|   protected $oCCaseProvisionStorage; | ||||
|  | ||||
|   /** | ||||
|    * The date formatter service. | ||||
|    * | ||||
|    * @var \Drupal\Core\Datetime\DateFormatterInterface | ||||
|    */ | ||||
|   protected $dateFormatter; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->oCCaseProvisionStorage = $container->get('entity_type.manager')->getStorage('oc_case_provision'); | ||||
|     $instance->dateFormatter = $container->get('date.formatter'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_provision_revision_revert_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to revert to the revision from %revision-date?', [ | ||||
|       '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_provision.version_history', ['oc_case_provision' => $this->revision->id()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Revert'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getDescription() { | ||||
|     return ''; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL) { | ||||
|     $this->revision = $this->OCCaseProvisionStorage->loadRevision($oc_case_provision_revision); | ||||
|     $form = parent::buildForm($form, $form_state); | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     // The revision timestamp will be updated when the revision is saved. Keep | ||||
|     // the original one for the confirmation message. | ||||
|     $original_revision_timestamp = $this->revision->getRevisionCreationTime(); | ||||
|  | ||||
|     $this->revision = $this->prepareRevertedRevision($this->revision, $form_state); | ||||
|     $this->revision->revision_log = $this->t('Copy of the revision from %date.', [ | ||||
|       '%date' => $this->dateFormatter->format($original_revision_timestamp), | ||||
|     ]); | ||||
|     $this->revision->save(); | ||||
|  | ||||
|     $this->logger('content')->notice('Case Provision: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     $this->messenger()->addMessage(t('Case Provision %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case_provision.version_history', | ||||
|       ['oc_case_provision' => $this->revision->id()] | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Prepares a revision to be reverted. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $revision | ||||
|    *   The revision to be reverted. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    * | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseProvisionInterface | ||||
|    *   The prepared revision ready to be stored. | ||||
|    */ | ||||
|   protected function prepareRevertedRevision(OCCaseProvisionInterface $revision, FormStateInterface $form_state) { | ||||
|     $revision->setNewRevision(); | ||||
|     $revision->isDefaultRevision(TRUE); | ||||
|     $revision->setRevisionCreationTime(REQUEST_TIME); | ||||
|  | ||||
|     return $revision; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvisionInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a form for reverting a Case Provision revision for a single trans. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionRevisionRevertTranslationForm extends OCCaseProvisionRevisionRevertForm { | ||||
|  | ||||
|   /** | ||||
|    * The language to be reverted. | ||||
|    * | ||||
|    * @var string | ||||
|    */ | ||||
|   protected $langcode; | ||||
|  | ||||
|   /** | ||||
|    * The language manager. | ||||
|    * | ||||
|    * @var \Drupal\Core\Language\LanguageManagerInterface | ||||
|    */ | ||||
|   protected $languageManager; | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public static function create(ContainerInterface $container) { | ||||
|     $instance = parent::create($container); | ||||
|     $instance->languageManager = $container->get('language_manager'); | ||||
|     return $instance; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'oc_case_provision_revision_revert_translation_confirm'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to revert @language translation to the revision from %revision-date?', [ | ||||
|       '@language' => $this->languageManager->getLanguageName($this->langcode), | ||||
|       '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state, $oc_case_provision_revision = NULL, $langcode = NULL) { | ||||
|     $this->langcode = $langcode; | ||||
|     $form = parent::buildForm($form, $form_state, $oc_case_provision_revision); | ||||
|  | ||||
|     $form['revert_untranslated_fields'] = [ | ||||
|       '#type' => 'checkbox', | ||||
|       '#title' => $this->t('Revert content shared among translations'), | ||||
|       '#default_value' => FALSE, | ||||
|     ]; | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function prepareRevertedRevision(OCCaseProvisionInterface $revision, FormStateInterface $form_state) { | ||||
|     $revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields'); | ||||
|  | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $default_revision */ | ||||
|     $latest_revision = $this->OCCaseProvisionStorage->load($revision->id()); | ||||
|     $latest_revision_translation = $latest_revision->getTranslation($this->langcode); | ||||
|  | ||||
|     $revision_translation = $revision->getTranslation($this->langcode); | ||||
|  | ||||
|     foreach ($latest_revision_translation->getFieldDefinitions() as $field_name => $definition) { | ||||
|       if ($definition->isTranslatable() || $revert_untranslated_fields) { | ||||
|         $latest_revision_translation->set($field_name, $revision_translation->get($field_name)->getValue()); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     $latest_revision_translation->setNewRevision(); | ||||
|     $latest_revision_translation->isDefaultRevision(TRUE); | ||||
|     $revision->setRevisionCreationTime(REQUEST_TIME); | ||||
|  | ||||
|     return $latest_revision_translation; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,53 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Form\FormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseProvisionSettingsForm. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionSettingsForm extends FormBase { | ||||
|  | ||||
|   /** | ||||
|    * Returns a unique string identifying the form. | ||||
|    * | ||||
|    * @return string | ||||
|    *   The unique string identifying the form. | ||||
|    */ | ||||
|   public function getFormId() { | ||||
|     return 'occaseprovision_settings'; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Form submission handler. | ||||
|    * | ||||
|    * @param array $form | ||||
|    *   An associative array containing the structure of the form. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     // Empty implementation of the abstract submit class. | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Defines the settings form for Case Provision entities. | ||||
|    * | ||||
|    * @param array $form | ||||
|    *   An associative array containing the structure of the form. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    * | ||||
|    * @return array | ||||
|    *   Form definition array. | ||||
|    */ | ||||
|   public function buildForm(array $form, FormStateInterface $form_state) { | ||||
|     $form['occaseprovision_settings']['#markup'] = 'Settings form for Case Provision entities. Manage field settings here.'; | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,51 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
|  | ||||
| /** | ||||
|  * Builds the form to delete Case Provision type entities. | ||||
|  */ | ||||
| class OCCaseProvisionTypeDeleteForm extends EntityConfirmFormBase { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getQuestion() { | ||||
|     return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getCancelUrl() { | ||||
|     return new Url('entity.oc_case_provision_type.collection'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getConfirmText() { | ||||
|     return $this->t('Delete'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     $this->entity->delete(); | ||||
|  | ||||
|     $this->messenger()->addMessage( | ||||
|       $this->t('content @type: deleted @label.', [ | ||||
|         '@type' => $this->entity->bundle(), | ||||
|         '@label' => $this->entity->label(), | ||||
|       ]) | ||||
|     ); | ||||
|  | ||||
|     $form_state->setRedirectUrl($this->getCancelUrl()); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										65
									
								
								modules/opencase_cases/src/Form/OCCaseProvisionTypeForm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								modules/opencase_cases/src/Form/OCCaseProvisionTypeForm.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Form; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
|  | ||||
| /** | ||||
|  * Class OCCaseProvisionTypeForm. | ||||
|  */ | ||||
| class OCCaseProvisionTypeForm extends EntityForm { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function form(array $form, FormStateInterface $form_state) { | ||||
|     $form = parent::form($form, $form_state); | ||||
|  | ||||
|     $oc_case_provision_type = $this->entity; | ||||
|     $form['label'] = [ | ||||
|       '#type' => 'textfield', | ||||
|       '#title' => $this->t('Label'), | ||||
|       '#maxlength' => 255, | ||||
|       '#default_value' => $oc_case_provision_type->label(), | ||||
|       '#description' => $this->t("Label for the Case Provision type."), | ||||
|       '#required' => TRUE, | ||||
|     ]; | ||||
|  | ||||
|     $form['id'] = [ | ||||
|       '#type' => 'machine_name', | ||||
|       '#default_value' => $oc_case_provision_type->id(), | ||||
|       '#machine_name' => [ | ||||
|         'exists' => '\Drupal\opencase_cases\Entity\OCCaseProvisionType::load', | ||||
|       ], | ||||
|       '#disabled' => !$oc_case_provision_type->isNew(), | ||||
|     ]; | ||||
|  | ||||
|     /* You will need additional form elements for your custom properties. */ | ||||
|  | ||||
|     return $form; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function save(array $form, FormStateInterface $form_state) { | ||||
|     $oc_case_provision_type = $this->entity; | ||||
|     $status = $oc_case_provision_type->save(); | ||||
|  | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         $this->messenger()->addMessage($this->t('Created the %label Case Provision type.', [ | ||||
|           '%label' => $oc_case_provision_type->label(), | ||||
|         ])); | ||||
|         break; | ||||
|  | ||||
|       default: | ||||
|         $this->messenger()->addMessage($this->t('Saved the %label Case Provision type.', [ | ||||
|           '%label' => $oc_case_provision_type->label(), | ||||
|         ])); | ||||
|     } | ||||
|     $form_state->setRedirectUrl($oc_case_provision_type->toUrl('collection')); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Database\Connection; | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| @ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
| /** | ||||
|  * Provides a form for deleting a Case revision. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseRevisionDeleteForm extends ConfirmFormBase { | ||||
| 
 | ||||
| @ -20,7 +20,7 @@ class OCCaseRevisionDeleteForm extends ConfirmFormBase { | ||||
|   /** | ||||
|    * The Case revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
| 
 | ||||
| @ -107,7 +107,7 @@ class OCCaseRevisionDeleteForm extends ConfirmFormBase { | ||||
|     $this->OCCaseStorage->deleteRevision($this->revision->getRevisionId()); | ||||
| 
 | ||||
|     $this->logger('content')->notice('Case: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     drupal_set_message(t('Revision from %revision-date of Case %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); | ||||
|     \Drupal::messenger()->addMessage(t('Revision from %revision-date of Case %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case.canonical', | ||||
|        ['oc_case' => $this->revision->id()] | ||||
| @ -1,19 +1,19 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Datetime\DateFormatterInterface; | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| use Drupal\Core\Form\ConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Url; | ||||
| use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
| 
 | ||||
| /** | ||||
|  * Provides a form for reverting a Case revision. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseRevisionRevertForm extends ConfirmFormBase { | ||||
| 
 | ||||
| @ -21,7 +21,7 @@ class OCCaseRevisionRevertForm extends ConfirmFormBase { | ||||
|   /** | ||||
|    * The Case revision. | ||||
|    * | ||||
|    * @var \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @var \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    */ | ||||
|   protected $revision; | ||||
| 
 | ||||
| @ -120,7 +120,7 @@ class OCCaseRevisionRevertForm extends ConfirmFormBase { | ||||
|     $this->revision->save(); | ||||
| 
 | ||||
|     $this->logger('content')->notice('Case: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); | ||||
|     drupal_set_message(t('Case %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); | ||||
|     \Drupal::messenger()->addMessage(t('Case %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); | ||||
|     $form_state->setRedirect( | ||||
|       'entity.oc_case.version_history', | ||||
|       ['oc_case' => $this->revision->id()] | ||||
| @ -130,12 +130,12 @@ class OCCaseRevisionRevertForm extends ConfirmFormBase { | ||||
|   /** | ||||
|    * Prepares a revision to be reverted. | ||||
|    * | ||||
|    * @param \Drupal\opencase_entities\Entity\OCCaseInterface $revision | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseInterface $revision | ||||
|    *   The revision to be reverted. | ||||
|    * @param \Drupal\Core\Form\FormStateInterface $form_state | ||||
|    *   The current state of the form. | ||||
|    * | ||||
|    * @return \Drupal\opencase_entities\Entity\OCCaseInterface | ||||
|    * @return \Drupal\opencase_cases\Entity\OCCaseInterface | ||||
|    *   The prepared revision ready to be stored. | ||||
|    */ | ||||
|   protected function prepareRevertedRevision(OCCaseInterface $revision, FormStateInterface $form_state) { | ||||
| @ -1,18 +1,18 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Datetime\DateFormatterInterface; | ||||
| use Drupal\Core\Entity\EntityStorageInterface; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| use Drupal\Core\Language\LanguageManagerInterface; | ||||
| use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||||
| 
 | ||||
| /** | ||||
|  * Provides a form for reverting a Case revision for a single translation. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseRevisionRevertTranslationForm extends OCCaseRevisionRevertForm { | ||||
| 
 | ||||
| @ -93,7 +93,7 @@ class OCCaseRevisionRevertTranslationForm extends OCCaseRevisionRevertForm { | ||||
|   protected function prepareRevertedRevision(OCCaseInterface $revision, FormStateInterface $form_state) { | ||||
|     $revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields'); | ||||
| 
 | ||||
|     /** @var \Drupal\opencase_entities\Entity\OCCaseInterface $default_revision */ | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseInterface $default_revision */ | ||||
|     $latest_revision = $this->OCCaseStorage->load($revision->id()); | ||||
|     $latest_revision_translation = $latest_revision->getTranslation($this->langcode); | ||||
| 
 | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Form\FormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| @ -8,7 +8,7 @@ use Drupal\Core\Form\FormStateInterface; | ||||
| /** | ||||
|  * Class OCCaseSettingsForm. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseSettingsForm extends FormBase { | ||||
| 
 | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityConfirmFormBase; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| @ -38,7 +38,7 @@ class OCCaseTypeDeleteForm extends EntityConfirmFormBase { | ||||
|   public function submitForm(array &$form, FormStateInterface $form_state) { | ||||
|     $this->entity->delete(); | ||||
| 
 | ||||
|     drupal_set_message( | ||||
|     \Drupal::messenger()->addMessage( | ||||
|       $this->t('content @type: deleted @label.', | ||||
|         [ | ||||
|           '@type' => $this->entity->bundle(), | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities\Form; | ||||
| namespace Drupal\opencase_cases\Form; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityForm; | ||||
| use Drupal\Core\Form\FormStateInterface; | ||||
| @ -30,7 +30,7 @@ class OCCaseTypeForm extends EntityForm { | ||||
|       '#type' => 'machine_name', | ||||
|       '#default_value' => $oc_case_type->id(), | ||||
|       '#machine_name' => [ | ||||
|         'exists' => '\Drupal\opencase_entities\Entity\OCCaseType::load', | ||||
|         'exists' => '\Drupal\opencase_cases\Entity\OCCaseType::load', | ||||
|       ], | ||||
|       '#disabled' => !$oc_case_type->isNew(), | ||||
|     ]; | ||||
| @ -49,13 +49,13 @@ class OCCaseTypeForm extends EntityForm { | ||||
| 
 | ||||
|     switch ($status) { | ||||
|       case SAVED_NEW: | ||||
|         drupal_set_message($this->t('Created the %label Case type.', [ | ||||
|         \Drupal::messenger()->addMessage($this->t('Created the %label Case type.', [ | ||||
|           '%label' => $oc_case_type->label(), | ||||
|         ])); | ||||
|         break; | ||||
| 
 | ||||
|       default: | ||||
|         drupal_set_message($this->t('Saved the %label Case type.', [ | ||||
|         \Drupal::messenger()->addMessage($this->t('Saved the %label Case type.', [ | ||||
|           '%label' => $oc_case_type->label(), | ||||
|         ])); | ||||
|     } | ||||
							
								
								
									
										9
									
								
								modules/opencase_cases/src/Helper/HookHelper.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								modules/opencase_cases/src/Helper/HookHelper.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases\Helper; | ||||
|  | ||||
| class HookHelper { | ||||
|     public static function onCaseFeeUpdate(\Drupal\opencase_cases\Entity\OCCaseFee $caseFee) { | ||||
|          | ||||
|     } | ||||
| } | ||||
| @ -1,17 +1,17 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityAccessControlHandler; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Access\AccessResult; | ||||
| use Drupal\opencase_entities\CaseInvolvement; | ||||
| use Drupal\opencase_cases\CaseInvolvement; | ||||
| 
 | ||||
| /** | ||||
|  * Access controller for the Case entity. | ||||
|  * | ||||
|  * @see \Drupal\opencase_entities\Entity\OCCase. | ||||
|  * @see \Drupal\opencase_cases\Entity\OCCase. | ||||
|  */ | ||||
| class OCCaseAccessControlHandler extends EntityAccessControlHandler { | ||||
| 
 | ||||
| @ -19,7 +19,7 @@ class OCCaseAccessControlHandler extends EntityAccessControlHandler { | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { | ||||
|     /** @var \Drupal\opencase_entities\Entity\OCCaseInterface $entity */ | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseInterface $entity */ | ||||
|     switch ($operation) { | ||||
|       case 'view': | ||||
|         if (!$entity->isPublished()) { | ||||
| @ -32,7 +32,6 @@ class OCCaseAccessControlHandler extends EntityAccessControlHandler { | ||||
|       case 'update':   // you can edit the case only if a) you can see it and b) you have the permission to edit cases.
 | ||||
|         return AccessResult::allowedIf( | ||||
|             $account->hasPermission('edit case entities') | ||||
|             && ($account->hasPermission('view published case entities') || CaseInvolvement::userIsInvolved($account, $entity)) | ||||
|         ); | ||||
|       case 'delete':   // you can delete the case only if a) you can see it and b) you have the permission to delete cases.
 | ||||
|         return AccessResult::allowedIf( | ||||
							
								
								
									
										116
									
								
								modules/opencase_cases/src/OCCaseFeeAccessControlHandler.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								modules/opencase_cases/src/OCCaseFeeAccessControlHandler.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,116 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityAccessControlHandler; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Access\AccessResult; | ||||
|  | ||||
| /** | ||||
|  * Access controller for the Case Fee entity. | ||||
|  * | ||||
|  * @see \Drupal\opencase_cases\Entity\OCCaseFee. | ||||
|  */ | ||||
| class OCCaseFeeAccessControlHandler extends EntityAccessControlHandler { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity */ | ||||
|  | ||||
|     switch ($operation) { | ||||
|  | ||||
|       case 'view': | ||||
|  | ||||
|         if (!$entity->isPublished()) { | ||||
|           $permission = $this->checkOwn($entity, 'view unpublished', $account); | ||||
|           if (!empty($permission)) { | ||||
|             return AccessResult::allowed(); | ||||
|           } | ||||
|  | ||||
|           return AccessResult::allowedIfHasPermission($account, 'view unpublished case fee entities'); | ||||
|         } | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|  | ||||
|         return AccessResult::allowedIfHasPermission($account, 'view published case fee entities'); | ||||
|  | ||||
|       case 'update': | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|         return AccessResult::allowedIfHasPermission($account, 'edit case fee entities'); | ||||
|  | ||||
|       case 'delete': | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|         return AccessResult::allowedIfHasPermission($account, 'delete case fee entities'); | ||||
|     } | ||||
|  | ||||
|     // Unknown operation, no opinion. | ||||
|     return AccessResult::neutral(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { | ||||
|     return AccessResult::allowedIfHasPermission($account, 'add case fee entities'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Test for given 'own' permission. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityInterface $entity | ||||
|    * @param $operation | ||||
|    * @param \Drupal\Core\Session\AccountInterface $account | ||||
|    * | ||||
|    * @return string|null | ||||
|    *   The permission string indicating it's allowed. | ||||
|    */ | ||||
|   protected function checkOwn(EntityInterface $entity, $operation, AccountInterface $account) { | ||||
|     $status = $entity->isPublished(); | ||||
|     $uid = $entity->getOwnerId(); | ||||
|  | ||||
|     $is_own = $account->isAuthenticated() && $account->id() == $uid; | ||||
|     if (!$is_own) { | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     $bundle = $entity->bundle(); | ||||
|  | ||||
|     $ops = [ | ||||
|       'create' => '%bundle add own %bundle entities', | ||||
|       'view unpublished' => '%bundle view own unpublished %bundle entities', | ||||
|       'view' => '%bundle view own entities', | ||||
|       'update' => '%bundle edit own entities', | ||||
|       'delete' => '%bundle delete own entities', | ||||
|     ]; | ||||
|     $permission = strtr($ops[$operation], ['%bundle' => $bundle]); | ||||
|  | ||||
|     if ($operation === 'view unpublished') { | ||||
|       if (!$status && $account->hasPermission($permission)) { | ||||
|         return $permission; | ||||
|       } | ||||
|       else { | ||||
|         return NULL; | ||||
|       } | ||||
|     } | ||||
|     if ($account->hasPermission($permission)) { | ||||
|       return $permission; | ||||
|     } | ||||
|  | ||||
|     return NULL; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										196
									
								
								modules/opencase_cases/src/OCCaseFeeHtmlRouteProvider.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								modules/opencase_cases/src/OCCaseFeeHtmlRouteProvider.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,196 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
| use Symfony\Component\Routing\Route; | ||||
|  | ||||
| /** | ||||
|  * Provides routes for Case Fee entities. | ||||
|  * | ||||
|  * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider | ||||
|  * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider | ||||
|  */ | ||||
| class OCCaseFeeHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getRoutes(EntityTypeInterface $entity_type) { | ||||
|     $collection = parent::getRoutes($entity_type); | ||||
|  | ||||
|     $entity_type_id = $entity_type->id(); | ||||
|  | ||||
|     if ($history_route = $this->getHistoryRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.version_history", $history_route); | ||||
|     } | ||||
|  | ||||
|     if ($revision_route = $this->getRevisionRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision", $revision_route); | ||||
|     } | ||||
|  | ||||
|     if ($revert_route = $this->getRevisionRevertRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision_revert", $revert_route); | ||||
|     } | ||||
|  | ||||
|     if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision_delete", $delete_route); | ||||
|     } | ||||
|  | ||||
|     if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) { | ||||
|       $collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route); | ||||
|     } | ||||
|  | ||||
|     if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) { | ||||
|       $collection->add("$entity_type_id.settings", $settings_form_route); | ||||
|     } | ||||
|  | ||||
|     return $collection; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the version history route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getHistoryRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('version-history')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('version-history')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_title' => "{$entity_type->getLabel()} revisions", | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionOverview', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'view all case fee revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionShow', | ||||
|           '_title_callback' => '\Drupal\opencase_cases\Controller\OCCaseFeeController::revisionPageTitle', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'view all case fee revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision revert route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionRevertRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision_revert')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionRevertForm', | ||||
|           '_title' => 'Revert to earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case fee revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision delete route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionDeleteRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision_delete')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_delete')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionDeleteForm', | ||||
|           '_title' => 'Delete earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'delete all case fee revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision translation revert route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionTranslationRevertRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('translation_revert')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('translation_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseFeeRevisionRevertTranslationForm', | ||||
|           '_title' => 'Revert to earlier revision of a translation', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case fee revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the settings form route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getSettingsFormRoute(EntityTypeInterface $entity_type) { | ||||
|     if (!$entity_type->getBundleEntityType()) { | ||||
|       $route = new Route("/admin/structure/{$entity_type->id()}/settings"); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => 'Drupal\opencase_cases\Form\OCCaseFeeSettingsForm', | ||||
|           '_title' => "{$entity_type->getLabel()} settings", | ||||
|         ]) | ||||
|         ->setRequirement('_permission', $entity_type->getAdminPermission()) | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										39
									
								
								modules/opencase_cases/src/OCCaseFeeListBuilder.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								modules/opencase_cases/src/OCCaseFeeListBuilder.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Entity\EntityListBuilder; | ||||
| use Drupal\Core\Link; | ||||
|  | ||||
| /** | ||||
|  * Defines a class to build a listing of Case Fee entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeListBuilder extends EntityListBuilder { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildHeader() { | ||||
|     $header['id'] = $this->t('Case Fee ID'); | ||||
|     $header['name'] = $this->t('Name'); | ||||
|     return $header + parent::buildHeader(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildRow(EntityInterface $entity) { | ||||
|     /* @var \Drupal\opencase_cases\Entity\OCCaseFee $entity */ | ||||
|     $row['id'] = $entity->id(); | ||||
|     $row['name'] = Link::createFromRoute( | ||||
|       $entity->label(), | ||||
|       'entity.oc_case_fee.edit_form', | ||||
|       ['oc_case_fee' => $entity->id()] | ||||
|     ); | ||||
|     return $row + parent::buildRow($entity); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										80
									
								
								modules/opencase_cases/src/OCCaseFeePermissions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								modules/opencase_cases/src/OCCaseFeePermissions.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,80 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\StringTranslation\StringTranslationTrait; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFee; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Provides dynamic permissions for Case Fee of different types. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  * | ||||
|  */ | ||||
| class OCCaseFeePermissions{ | ||||
|  | ||||
|   use StringTranslationTrait; | ||||
|  | ||||
|   /** | ||||
|    * Returns an array of node type permissions. | ||||
|    * | ||||
|    * @return array | ||||
|    *   The OCCaseFee by bundle permissions. | ||||
|    *   @see \Drupal\user\PermissionHandlerInterface::getPermissions() | ||||
|    */ | ||||
|   public function generatePermissions() { | ||||
|     $perms = []; | ||||
|  | ||||
|     foreach (OCCaseFee::loadMultiple() as $type) { | ||||
|       $perms += $this->buildPermissions($type); | ||||
|     } | ||||
|  | ||||
|     return $perms; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Returns a list of node permissions for a given node type. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseFee $type | ||||
|    *   The OCCaseFee type. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An associative array of permission names and descriptions. | ||||
|    */ | ||||
|   protected function buildPermissions(OCCaseFee $type) { | ||||
|     $type_id = $type->id(); | ||||
|     $type_params = ['%type_name' => $type->label()]; | ||||
|  | ||||
|     return [ | ||||
|       "$type_id create entities" => [ | ||||
|         'title' => $this->t('Create new %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id edit own entities" => [ | ||||
|         'title' => $this->t('Edit own %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id edit any entities" => [ | ||||
|         'title' => $this->t('Edit any %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id delete own entities" => [ | ||||
|         'title' => $this->t('Delete own %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id delete any entities" => [ | ||||
|         'title' => $this->t('Delete any %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id view revisions" => [ | ||||
|         'title' => $this->t('View %type_name revisions', $type_params), | ||||
|         'description' => t('To view a revision, you also need permission to view the entity item.'), | ||||
|       ], | ||||
|       "$type_id revert revisions" => [ | ||||
|         'title' => $this->t('Revert %type_name revisions', $type_params), | ||||
|         'description' => t('To revert a revision, you also need permission to edit the entity item.'), | ||||
|       ], | ||||
|       "$type_id delete revisions" => [ | ||||
|         'title' => $this->t('Delete %type_name revisions', $type_params), | ||||
|         'description' => $this->t('To delete a revision, you also need permission to delete the entity item.'), | ||||
|       ], | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										58
									
								
								modules/opencase_cases/src/OCCaseFeeStorage.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								modules/opencase_cases/src/OCCaseFeeStorage.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\Sql\SqlContentEntityStorage; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFeeInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the storage handler class for Case Fee entities. | ||||
|  * | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case Fee entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseFeeStorage extends SqlContentEntityStorage implements OCCaseFeeStorageInterface { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function revisionIds(OCCaseFeeInterface $entity) { | ||||
|     return $this->database->query( | ||||
|       'SELECT vid FROM {oc_case_fee_revision} WHERE id=:id ORDER BY vid', | ||||
|       [':id' => $entity->id()] | ||||
|     )->fetchCol(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function userRevisionIds(AccountInterface $account) { | ||||
|     return $this->database->query( | ||||
|       'SELECT vid FROM {oc_case_fee_field_revision} WHERE uid = :uid ORDER BY vid', | ||||
|       [':uid' => $account->id()] | ||||
|     )->fetchCol(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function countDefaultLanguageRevisions(OCCaseFeeInterface $entity) { | ||||
|     return $this->database->query('SELECT COUNT(*) FROM {oc_case_fee_field_revision} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()]) | ||||
|       ->fetchField(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function clearRevisionsLanguage(LanguageInterface $language) { | ||||
|     return $this->database->update('oc_case_fee_revision') | ||||
|       ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]) | ||||
|       ->condition('langcode', $language->getId()) | ||||
|       ->execute(); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										61
									
								
								modules/opencase_cases/src/OCCaseFeeStorageInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								modules/opencase_cases/src/OCCaseFeeStorageInterface.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,61 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityStorageInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseFeeInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the storage handler class for Case Fee entities. | ||||
|  * | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case Fee entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseFeeStorageInterface extends ContentEntityStorageInterface { | ||||
|  | ||||
|   /** | ||||
|    * Gets a list of Case Fee revision IDs for a specific Case Fee. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity | ||||
|    *   The Case Fee entity. | ||||
|    * | ||||
|    * @return int[] | ||||
|    *   Case Fee revision IDs (in ascending order). | ||||
|    */ | ||||
|   public function revisionIds(OCCaseFeeInterface $entity); | ||||
|  | ||||
|   /** | ||||
|    * Gets a list of revision IDs having a given user as Case Fee author. | ||||
|    * | ||||
|    * @param \Drupal\Core\Session\AccountInterface $account | ||||
|    *   The user entity. | ||||
|    * | ||||
|    * @return int[] | ||||
|    *   Case Fee revision IDs (in ascending order). | ||||
|    */ | ||||
|   public function userRevisionIds(AccountInterface $account); | ||||
|  | ||||
|   /** | ||||
|    * Counts the number of revisions in the default language. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseFeeInterface $entity | ||||
|    *   The Case Fee entity. | ||||
|    * | ||||
|    * @return int | ||||
|    *   The number of revisions in the default language. | ||||
|    */ | ||||
|   public function countDefaultLanguageRevisions(OCCaseFeeInterface $entity); | ||||
|  | ||||
|   /** | ||||
|    * Unsets the language for all Case Fee with the given language. | ||||
|    * | ||||
|    * @param \Drupal\Core\Language\LanguageInterface $language | ||||
|    *   The language object. | ||||
|    */ | ||||
|   public function clearRevisionsLanguage(LanguageInterface $language); | ||||
|  | ||||
| } | ||||
							
								
								
									
										13
									
								
								modules/opencase_cases/src/OCCaseFeeTranslationHandler.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								modules/opencase_cases/src/OCCaseFeeTranslationHandler.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\content_translation\ContentTranslationHandler; | ||||
|  | ||||
| /** | ||||
|  * Defines the translation handler for oc_case_fee. | ||||
|  */ | ||||
| class OCCaseFeeTranslationHandler extends ContentTranslationHandler { | ||||
|  | ||||
|   // Override here the needed methods from ContentTranslationHandler. | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
|  | ||||
| /** | ||||
|  * Provides routes for Case Fee type entities. | ||||
|  * | ||||
|  * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider | ||||
|  * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider | ||||
|  */ | ||||
| class OCCaseFeeTypeHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getRoutes(EntityTypeInterface $entity_type) { | ||||
|     $collection = parent::getRoutes($entity_type); | ||||
|  | ||||
|     // Provide your custom entity routes here. | ||||
|     return $collection; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										32
									
								
								modules/opencase_cases/src/OCCaseFeeTypeListBuilder.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								modules/opencase_cases/src/OCCaseFeeTypeListBuilder.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityListBuilder; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a listing of Case Fee type entities. | ||||
|  */ | ||||
| class OCCaseFeeTypeListBuilder extends ConfigEntityListBuilder { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildHeader() { | ||||
|     $header['label'] = $this->t('Case Fee type'); | ||||
|     $header['id'] = $this->t('Machine name'); | ||||
|     return $header + parent::buildHeader(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildRow(EntityInterface $entity) { | ||||
|     $row['label'] = $entity->label(); | ||||
|     $row['id'] = $entity->id(); | ||||
|     // You probably want a few more properties here... | ||||
|     return $row + parent::buildRow($entity); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
| @ -64,7 +64,7 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_title' => "{$entity_type->getLabel()} revisions", | ||||
|           '_controller' => '\Drupal\opencase_entities\Controller\OCCaseController::revisionOverview', | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseController::revisionOverview', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'access case revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
| @ -87,8 +87,8 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_controller' => '\Drupal\opencase_entities\Controller\OCCaseController::revisionShow', | ||||
|           '_title_callback' => '\Drupal\opencase_entities\Controller\OCCaseController::revisionPageTitle', | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseController::revisionShow', | ||||
|           '_title_callback' => '\Drupal\opencase_cases\Controller\OCCaseController::revisionPageTitle', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'access case revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
| @ -111,7 +111,7 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_entities\Form\OCCaseRevisionRevertForm', | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseRevisionRevertForm', | ||||
|           '_title' => 'Revert to earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case revisions') | ||||
| @ -135,7 +135,7 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_delete')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_entities\Form\OCCaseRevisionDeleteForm', | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseRevisionDeleteForm', | ||||
|           '_title' => 'Delete earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'delete all case revisions') | ||||
| @ -159,7 +159,7 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route = new Route($entity_type->getLinkTemplate('translation_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_entities\Form\OCCaseRevisionRevertTranslationForm', | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseRevisionRevertTranslationForm', | ||||
|           '_title' => 'Revert to earlier revision of a translation', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case revisions') | ||||
| @ -183,7 +183,7 @@ class OCCaseHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|       $route = new Route("/admin/structure/{$entity_type->id()}/settings"); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => 'Drupal\opencase_entities\Form\OCCaseSettingsForm', | ||||
|           '_form' => 'Drupal\opencase_cases\Form\OCCaseSettingsForm', | ||||
|           '_title' => "{$entity_type->getLabel()} settings", | ||||
|         ]) | ||||
|         ->setRequirement('_permission', $entity_type->getAdminPermission()) | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Entity\EntityListBuilder; | ||||
| @ -9,7 +9,7 @@ use Drupal\Core\Link; | ||||
| /** | ||||
|  * Defines a class to build a listing of Case entities. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseListBuilder extends EntityListBuilder { | ||||
| 
 | ||||
| @ -27,7 +27,7 @@ class OCCaseListBuilder extends EntityListBuilder { | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildRow(EntityInterface $entity) { | ||||
|     /* @var $entity \Drupal\opencase_entities\Entity\OCCase */ | ||||
|     /* @var $entity \Drupal\opencase_cases\Entity\OCCase */ | ||||
|     $row['id'] = $entity->id(); | ||||
|     $row['name'] = Link::createFromRoute( | ||||
|       $entity->label(), | ||||
| @ -0,0 +1,116 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityAccessControlHandler; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Access\AccessResult; | ||||
|  | ||||
| /** | ||||
|  * Access controller for the Case Provision entity. | ||||
|  * | ||||
|  * @see \Drupal\opencase_cases\Entity\OCCaseProvision. | ||||
|  */ | ||||
| class OCCaseProvisionAccessControlHandler extends EntityAccessControlHandler { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { | ||||
|     /** @var \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity */ | ||||
|  | ||||
|     switch ($operation) { | ||||
|  | ||||
|       case 'view': | ||||
|  | ||||
|         if (!$entity->isPublished()) { | ||||
|           $permission = $this->checkOwn($entity, 'view unpublished', $account); | ||||
|           if (!empty($permission)) { | ||||
|             return AccessResult::allowed(); | ||||
|           } | ||||
|  | ||||
|           return AccessResult::allowedIfHasPermission($account, 'view unpublished case provision entities'); | ||||
|         } | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|  | ||||
|         return AccessResult::allowedIfHasPermission($account, 'view published case provision entities'); | ||||
|  | ||||
|       case 'update': | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|         return AccessResult::allowedIfHasPermission($account, 'edit case provision entities'); | ||||
|  | ||||
|       case 'delete': | ||||
|  | ||||
|         $permission = $this->checkOwn($entity, $operation, $account); | ||||
|         if (!empty($permission)) { | ||||
|           return AccessResult::allowed(); | ||||
|         } | ||||
|         return AccessResult::allowedIfHasPermission($account, 'delete case provision entities'); | ||||
|     } | ||||
|  | ||||
|     // Unknown operation, no opinion. | ||||
|     return AccessResult::neutral(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { | ||||
|     return AccessResult::allowedIfHasPermission($account, 'add case provision entities'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Test for given 'own' permission. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityInterface $entity | ||||
|    * @param $operation | ||||
|    * @param \Drupal\Core\Session\AccountInterface $account | ||||
|    * | ||||
|    * @return string|null | ||||
|    *   The permission string indicating it's allowed. | ||||
|    */ | ||||
|   protected function checkOwn(EntityInterface $entity, $operation, AccountInterface $account) { | ||||
|     $status = $entity->isPublished(); | ||||
|     $uid = $entity->getOwnerId(); | ||||
|  | ||||
|     $is_own = $account->isAuthenticated() && $account->id() == $uid; | ||||
|     if (!$is_own) { | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     $bundle = $entity->bundle(); | ||||
|  | ||||
|     $ops = [ | ||||
|       'create' => '%bundle add own %bundle entities', | ||||
|       'view unpublished' => '%bundle view own unpublished %bundle entities', | ||||
|       'view' => '%bundle view own entities', | ||||
|       'update' => '%bundle edit own entities', | ||||
|       'delete' => '%bundle delete own entities', | ||||
|     ]; | ||||
|     $permission = strtr($ops[$operation], ['%bundle' => $bundle]); | ||||
|  | ||||
|     if ($operation === 'view unpublished') { | ||||
|       if (!$status && $account->hasPermission($permission)) { | ||||
|         return $permission; | ||||
|       } | ||||
|       else { | ||||
|         return NULL; | ||||
|       } | ||||
|     } | ||||
|     if ($account->hasPermission($permission)) { | ||||
|       return $permission; | ||||
|     } | ||||
|  | ||||
|     return NULL; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										196
									
								
								modules/opencase_cases/src/OCCaseProvisionHtmlRouteProvider.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										196
									
								
								modules/opencase_cases/src/OCCaseProvisionHtmlRouteProvider.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,196 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
| use Symfony\Component\Routing\Route; | ||||
|  | ||||
| /** | ||||
|  * Provides routes for Case Provision entities. | ||||
|  * | ||||
|  * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider | ||||
|  * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider | ||||
|  */ | ||||
| class OCCaseProvisionHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getRoutes(EntityTypeInterface $entity_type) { | ||||
|     $collection = parent::getRoutes($entity_type); | ||||
|  | ||||
|     $entity_type_id = $entity_type->id(); | ||||
|  | ||||
|     if ($history_route = $this->getHistoryRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.version_history", $history_route); | ||||
|     } | ||||
|  | ||||
|     if ($revision_route = $this->getRevisionRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision", $revision_route); | ||||
|     } | ||||
|  | ||||
|     if ($revert_route = $this->getRevisionRevertRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision_revert", $revert_route); | ||||
|     } | ||||
|  | ||||
|     if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) { | ||||
|       $collection->add("entity.{$entity_type_id}.revision_delete", $delete_route); | ||||
|     } | ||||
|  | ||||
|     if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) { | ||||
|       $collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route); | ||||
|     } | ||||
|  | ||||
|     if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) { | ||||
|       $collection->add("$entity_type_id.settings", $settings_form_route); | ||||
|     } | ||||
|  | ||||
|     return $collection; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the version history route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getHistoryRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('version-history')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('version-history')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_title' => "{$entity_type->getLabel()} revisions", | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionOverview', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'view all case provision revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_controller' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionShow', | ||||
|           '_title_callback' => '\Drupal\opencase_cases\Controller\OCCaseProvisionController::revisionPageTitle', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'view all case provision revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision revert route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionRevertRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision_revert')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionRevertForm', | ||||
|           '_title' => 'Revert to earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case provision revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision delete route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionDeleteRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('revision_delete')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('revision_delete')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionDeleteForm', | ||||
|           '_title' => 'Delete earlier revision', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'delete all case provision revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision translation revert route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getRevisionTranslationRevertRoute(EntityTypeInterface $entity_type) { | ||||
|     if ($entity_type->hasLinkTemplate('translation_revert')) { | ||||
|       $route = new Route($entity_type->getLinkTemplate('translation_revert')); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => '\Drupal\opencase_cases\Form\OCCaseProvisionRevisionRevertTranslationForm', | ||||
|           '_title' => 'Revert to earlier revision of a translation', | ||||
|         ]) | ||||
|         ->setRequirement('_permission', 'revert all case provision revisions') | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the settings form route. | ||||
|    * | ||||
|    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | ||||
|    *   The entity type. | ||||
|    * | ||||
|    * @return \Symfony\Component\Routing\Route|null | ||||
|    *   The generated route, if available. | ||||
|    */ | ||||
|   protected function getSettingsFormRoute(EntityTypeInterface $entity_type) { | ||||
|     if (!$entity_type->getBundleEntityType()) { | ||||
|       $route = new Route("/admin/structure/{$entity_type->id()}/settings"); | ||||
|       $route | ||||
|         ->setDefaults([ | ||||
|           '_form' => 'Drupal\opencase_cases\Form\OCCaseProvisionSettingsForm', | ||||
|           '_title' => "{$entity_type->getLabel()} settings", | ||||
|         ]) | ||||
|         ->setRequirement('_permission', $entity_type->getAdminPermission()) | ||||
|         ->setOption('_admin_route', TRUE); | ||||
|  | ||||
|       return $route; | ||||
|     } | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										39
									
								
								modules/opencase_cases/src/OCCaseProvisionListBuilder.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								modules/opencase_cases/src/OCCaseProvisionListBuilder.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| use Drupal\Core\Entity\EntityListBuilder; | ||||
| use Drupal\Core\Link; | ||||
|  | ||||
| /** | ||||
|  * Defines a class to build a listing of Case Provision entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionListBuilder extends EntityListBuilder { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildHeader() { | ||||
|     $header['id'] = $this->t('Case Provision ID'); | ||||
|     $header['name'] = $this->t('Name'); | ||||
|     return $header + parent::buildHeader(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildRow(EntityInterface $entity) { | ||||
|     /* @var \Drupal\opencase_cases\Entity\OCCaseProvision $entity */ | ||||
|     $row['id'] = $entity->id(); | ||||
|     $row['name'] = Link::createFromRoute( | ||||
|       $entity->label(), | ||||
|       'entity.oc_case_provision.edit_form', | ||||
|       ['oc_case_provision' => $entity->id()] | ||||
|     ); | ||||
|     return $row + parent::buildRow($entity); | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										80
									
								
								modules/opencase_cases/src/OCCaseProvisionPermissions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								modules/opencase_cases/src/OCCaseProvisionPermissions.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,80 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\StringTranslation\StringTranslationTrait; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvision; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Provides dynamic permissions for Case Provision of different types. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  * | ||||
|  */ | ||||
| class OCCaseProvisionPermissions{ | ||||
|  | ||||
|   use StringTranslationTrait; | ||||
|  | ||||
|   /** | ||||
|    * Returns an array of node type permissions. | ||||
|    * | ||||
|    * @return array | ||||
|    *   The OCCaseProvision by bundle permissions. | ||||
|    *   @see \Drupal\user\PermissionHandlerInterface::getPermissions() | ||||
|    */ | ||||
|   public function generatePermissions() { | ||||
|     $perms = []; | ||||
|  | ||||
|     foreach (OCCaseProvision::loadMultiple() as $type) { | ||||
|       $perms += $this->buildPermissions($type); | ||||
|     } | ||||
|  | ||||
|     return $perms; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Returns a list of node permissions for a given node type. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseProvision $type | ||||
|    *   The OCCaseProvision type. | ||||
|    * | ||||
|    * @return array | ||||
|    *   An associative array of permission names and descriptions. | ||||
|    */ | ||||
|   protected function buildPermissions(OCCaseProvision $type) { | ||||
|     $type_id = $type->id(); | ||||
|     $type_params = ['%type_name' => $type->label()]; | ||||
|  | ||||
|     return [ | ||||
|       "$type_id create entities" => [ | ||||
|         'title' => $this->t('Create new %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id edit own entities" => [ | ||||
|         'title' => $this->t('Edit own %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id edit any entities" => [ | ||||
|         'title' => $this->t('Edit any %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id delete own entities" => [ | ||||
|         'title' => $this->t('Delete own %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id delete any entities" => [ | ||||
|         'title' => $this->t('Delete any %type_name entities', $type_params), | ||||
|       ], | ||||
|       "$type_id view revisions" => [ | ||||
|         'title' => $this->t('View %type_name revisions', $type_params), | ||||
|         'description' => t('To view a revision, you also need permission to view the entity item.'), | ||||
|       ], | ||||
|       "$type_id revert revisions" => [ | ||||
|         'title' => $this->t('Revert %type_name revisions', $type_params), | ||||
|         'description' => t('To revert a revision, you also need permission to edit the entity item.'), | ||||
|       ], | ||||
|       "$type_id delete revisions" => [ | ||||
|         'title' => $this->t('Delete %type_name revisions', $type_params), | ||||
|         'description' => $this->t('To delete a revision, you also need permission to delete the entity item.'), | ||||
|       ], | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										58
									
								
								modules/opencase_cases/src/OCCaseProvisionStorage.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								modules/opencase_cases/src/OCCaseProvisionStorage.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\Sql\SqlContentEntityStorage; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvisionInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the storage handler class for Case Provision entities. | ||||
|  * | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case Provision entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseProvisionStorage extends SqlContentEntityStorage implements OCCaseProvisionStorageInterface { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function revisionIds(OCCaseProvisionInterface $entity) { | ||||
|     return $this->database->query( | ||||
|       'SELECT vid FROM {oc_case_provision_revision} WHERE id=:id ORDER BY vid', | ||||
|       [':id' => $entity->id()] | ||||
|     )->fetchCol(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function userRevisionIds(AccountInterface $account) { | ||||
|     return $this->database->query( | ||||
|       'SELECT vid FROM {oc_case_provision_field_revision} WHERE uid = :uid ORDER BY vid', | ||||
|       [':uid' => $account->id()] | ||||
|     )->fetchCol(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function countDefaultLanguageRevisions(OCCaseProvisionInterface $entity) { | ||||
|     return $this->database->query('SELECT COUNT(*) FROM {oc_case_provision_field_revision} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()]) | ||||
|       ->fetchField(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function clearRevisionsLanguage(LanguageInterface $language) { | ||||
|     return $this->database->update('oc_case_provision_revision') | ||||
|       ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]) | ||||
|       ->condition('langcode', $language->getId()) | ||||
|       ->execute(); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,61 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\ContentEntityStorageInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseProvisionInterface; | ||||
|  | ||||
| /** | ||||
|  * Defines the storage handler class for Case Provision entities. | ||||
|  * | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case Provision entities. | ||||
|  * | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseProvisionStorageInterface extends ContentEntityStorageInterface { | ||||
|  | ||||
|   /** | ||||
|    * Gets a list of Case Provision revision IDs for a specific Case Provision. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity | ||||
|    *   The Case Provision entity. | ||||
|    * | ||||
|    * @return int[] | ||||
|    *   Case Provision revision IDs (in ascending order). | ||||
|    */ | ||||
|   public function revisionIds(OCCaseProvisionInterface $entity); | ||||
|  | ||||
|   /** | ||||
|    * Gets a list of revision IDs having a given user as Case Provision author. | ||||
|    * | ||||
|    * @param \Drupal\Core\Session\AccountInterface $account | ||||
|    *   The user entity. | ||||
|    * | ||||
|    * @return int[] | ||||
|    *   Case Provision revision IDs (in ascending order). | ||||
|    */ | ||||
|   public function userRevisionIds(AccountInterface $account); | ||||
|  | ||||
|   /** | ||||
|    * Counts the number of revisions in the default language. | ||||
|    * | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseProvisionInterface $entity | ||||
|    *   The Case Provision entity. | ||||
|    * | ||||
|    * @return int | ||||
|    *   The number of revisions in the default language. | ||||
|    */ | ||||
|   public function countDefaultLanguageRevisions(OCCaseProvisionInterface $entity); | ||||
|  | ||||
|   /** | ||||
|    * Unsets the language for all Case Provision with the given language. | ||||
|    * | ||||
|    * @param \Drupal\Core\Language\LanguageInterface $language | ||||
|    *   The language object. | ||||
|    */ | ||||
|   public function clearRevisionsLanguage(LanguageInterface $language); | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,13 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\content_translation\ContentTranslationHandler; | ||||
|  | ||||
| /** | ||||
|  * Defines the translation handler for oc_case_provision. | ||||
|  */ | ||||
| class OCCaseProvisionTranslationHandler extends ContentTranslationHandler { | ||||
|  | ||||
|   // Override here the needed methods from ContentTranslationHandler. | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
|  | ||||
| /** | ||||
|  * Provides routes for Case Provision type entities. | ||||
|  * | ||||
|  * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider | ||||
|  * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider | ||||
|  */ | ||||
| class OCCaseProvisionTypeHtmlRouteProvider extends AdminHtmlRouteProvider { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function getRoutes(EntityTypeInterface $entity_type) { | ||||
|     $collection = parent::getRoutes($entity_type); | ||||
|  | ||||
|     // Provide your custom entity routes here. | ||||
|     return $collection; | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Drupal\opencase_cases; | ||||
|  | ||||
| use Drupal\Core\Config\Entity\ConfigEntityListBuilder; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
|  | ||||
| /** | ||||
|  * Provides a listing of Case Provision type entities. | ||||
|  */ | ||||
| class OCCaseProvisionTypeListBuilder extends ConfigEntityListBuilder { | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildHeader() { | ||||
|     $header['label'] = $this->t('Case Provision type'); | ||||
|     $header['id'] = $this->t('Machine name'); | ||||
|     return $header + parent::buildHeader(); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * {@inheritdoc} | ||||
|    */ | ||||
|   public function buildRow(EntityInterface $entity) { | ||||
|     $row['label'] = $entity->label(); | ||||
|     $row['id'] = $entity->id(); | ||||
|     // You probably want a few more properties here... | ||||
|     return $row + parent::buildRow($entity); | ||||
|   } | ||||
|  | ||||
| } | ||||
| @ -1,11 +1,11 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\Sql\SqlContentEntityStorage; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseInterface; | ||||
| 
 | ||||
| /** | ||||
|  * Defines the storage handler class for Case entities. | ||||
| @ -13,7 +13,7 @@ use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case entities. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| class OCCaseStorage extends SqlContentEntityStorage implements OCCaseStorageInterface { | ||||
| 
 | ||||
| @ -1,11 +1,11 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\ContentEntityStorageInterface; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| use Drupal\Core\Language\LanguageInterface; | ||||
| use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
| use Drupal\opencase_cases\Entity\OCCaseInterface; | ||||
| 
 | ||||
| /** | ||||
|  * Defines the storage handler class for Case entities. | ||||
| @ -13,14 +13,14 @@ use Drupal\opencase_entities\Entity\OCCaseInterface; | ||||
|  * This extends the base storage class, adding required special handling for | ||||
|  * Case entities. | ||||
|  * | ||||
|  * @ingroup opencase_entities | ||||
|  * @ingroup opencase_cases | ||||
|  */ | ||||
| interface OCCaseStorageInterface extends ContentEntityStorageInterface { | ||||
| 
 | ||||
|   /** | ||||
|    * Gets a list of Case revision IDs for a specific Case. | ||||
|    * | ||||
|    * @param \Drupal\opencase_entities\Entity\OCCaseInterface $entity | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseInterface $entity | ||||
|    *   The Case entity. | ||||
|    * | ||||
|    * @return int[] | ||||
| @ -42,7 +42,7 @@ interface OCCaseStorageInterface extends ContentEntityStorageInterface { | ||||
|   /** | ||||
|    * Counts the number of revisions in the default language. | ||||
|    * | ||||
|    * @param \Drupal\opencase_entities\Entity\OCCaseInterface $entity | ||||
|    * @param \Drupal\opencase_cases\Entity\OCCaseInterface $entity | ||||
|    *   The Case entity. | ||||
|    * | ||||
|    * @return int | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\content_translation\ContentTranslationHandler; | ||||
| 
 | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityAccessControlHandler; | ||||
| use Drupal\Core\Session\AccountInterface; | ||||
| @ -11,7 +11,7 @@ use Drupal\Core\Access\AccessResult; | ||||
|  * Defines the access control handler for the OCCaseType Config Entity. | ||||
|  * Always allows viewing the label of the bundle. | ||||
|  * | ||||
|  * @see Drupal\opencase_entities\Entity\OCCaseType | ||||
|  * @see Drupal\opencase_cases\Entity\OCCaseType | ||||
|  */ | ||||
| class OCCaseTypeAccessControlHandler extends EntityAccessControlHandler { | ||||
| 
 | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Entity\EntityTypeInterface; | ||||
| use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Drupal\opencase_entities; | ||||
| namespace Drupal\opencase_cases; | ||||
| 
 | ||||
| use Drupal\Core\Config\Entity\ConfigEntityListBuilder; | ||||
| use Drupal\Core\Entity\EntityInterface; | ||||
| @ -0,0 +1,23 @@ | ||||
| {# | ||||
| /** | ||||
|  * @file | ||||
|  * Default theme implementation to present a list of custom content entity types/bundles. | ||||
|  * | ||||
|  * Available variables: | ||||
|  * - types: A collection of all the available custom entity types/bundles. | ||||
|  *   Each type/bundle contains the following: | ||||
|  *   - link: A link to add a content entity of this type. | ||||
|  *   - description: A description of this content entity types/bundle. | ||||
|  * | ||||
|  * @see template_preprocess_oc_activity_content_add_list() | ||||
|  * | ||||
|  * @ingroup themeable | ||||
|  */ | ||||
| #} | ||||
| {% spaceless %} | ||||
|   <dl> | ||||
|     {% for id,type in bundles %} | ||||
|       <dt><a href="/opencase/oc_case/add/{{ id }}?client_id={{ client_id }}">{{ type.label }}</a></dt> | ||||
|     {% endfor %} | ||||
|   </dl> | ||||
| {% endspaceless %} | ||||
| @ -0,0 +1,23 @@ | ||||
| {# | ||||
| /** | ||||
|  * @file | ||||
|  * Default theme implementation to present a list of custom content entity types/bundles. | ||||
|  * | ||||
|  * Available variables: | ||||
|  * - types: A collection of all the available custom entity types/bundles. | ||||
|  *   Each type/bundle contains the following: | ||||
|  *   - link: A link to add a content entity of this type. | ||||
|  *   - description: A description of this content entity types/bundle. | ||||
|  * | ||||
|  * @see template_preprocess_oc_case_fee_content_add_list() | ||||
|  * | ||||
|  * @ingroup themeable | ||||
|  */ | ||||
| #} | ||||
| {% spaceless %} | ||||
|   <dl> | ||||
|     {% for type in types %} | ||||
|       <dt>{{ type.link }}</dt> | ||||
|     {% endfor %} | ||||
|   </dl> | ||||
| {% endspaceless %} | ||||
| @ -0,0 +1,23 @@ | ||||
| {# | ||||
| /** | ||||
|  * @file | ||||
|  * Default theme implementation to present a list of custom content entity types/bundles. | ||||
|  * | ||||
|  * Available variables: | ||||
|  * - types: A collection of all the available custom entity types/bundles. | ||||
|  *   Each type/bundle contains the following: | ||||
|  *   - link: A link to add a content entity of this type. | ||||
|  *   - description: A description of this content entity types/bundle. | ||||
|  * | ||||
|  * @see template_preprocess_oc_case_provision_content_add_list() | ||||
|  * | ||||
|  * @ingroup themeable | ||||
|  */ | ||||
| #} | ||||
| {% spaceless %} | ||||
|   <dl> | ||||
|     {% for type in types %} | ||||
|       <dt>{{ type.link }}</dt> | ||||
|     {% endfor %} | ||||
|   </dl> | ||||
| {% endspaceless %} | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	