-
Notifications
You must be signed in to change notification settings - Fork 3
/
oe_translation.install
147 lines (136 loc) · 5.63 KB
/
oe_translation.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* @file
* OpenEuropa Translation install file.
*/
use Drupal\Core\Config\Entity\ConfigEntityType;
use Drupal\Core\Entity\ContentEntityType;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\oe_translation\Entity\TranslationRequest;
use Drupal\oe_translation\Entity\TranslationRequestLog;
use Drupal\oe_translation\Entity\TranslationRequestType;
/**
* Creates the revision ID field on the TMGMT job item entity.
*/
function oe_translation_update_8001(&$sandbox) {
$field = BaseFieldDefinition::create('integer')
->setLabel(new TranslatableMarkup('Item revision ID'))
->setSetting('unsigned', TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('item_rid', 'tmgmt_job_item', 'oe_translation', $field);
}
/**
* Creates the Item bundle field on the TMGMT job item entity.
*/
function oe_translation_update_8002(&$sandbox) {
$field = BaseFieldDefinition::create('string')
->setLabel(new TranslatableMarkup('Item bundle'));
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('item_bundle', 'tmgmt_job_item', 'oe_translation', $field);
}
/**
* Installs new entity types and modules.
*/
function oe_translation_update_9001(): void {
// Install the new entity types.
$update_manager = \Drupal::entityDefinitionUpdateManager();
$translation_request_entity_type = [
'id' => 'oe_translation_request',
'label' => new TranslatableMarkup('Translation Request'),
'label_collection' => new TranslatableMarkup('Translation Requests'),
'bundle_label' => new TranslatableMarkup('Translation Request type'),
'handlers' => [
'list_builder' => 'Drupal\oe_translation\TranslationRequestListBuilder',
'views_data' => 'Drupal\views\EntityViewsData',
'access' => 'Drupal\oe_translation\Access\TranslationRequestAccessControlHandler',
'form' => [
'default' => 'Drupal\oe_translation\Form\TranslationRequestForm',
'add' => 'Drupal\oe_translation\Form\TranslationRequestForm',
'edit' => 'Drupal\oe_translation\Form\TranslationRequestForm',
'delete' => 'Drupal\Core\Entity\ContentEntityDeleteForm',
],
'route_provider' => [
'html' => 'Drupal\oe_translation\Routing\TranslationRequestRouteProvider',
],
],
'base_table' => 'oe_translation_request',
'admin_permission' => 'administer translation requests',
'entity_keys' => [
'id' => 'id',
'bundle' => 'bundle',
'label' => 'id',
'uuid' => 'uuid',
'created' => 'created',
'changed' => 'changed',
'published' => 'status',
'owner' => 'uid',
],
'links' => [
'add-form' => '/translation-request/add/{oe_translation_request_type}',
'add-page' => '/translation-request/add',
'canonical' => '/translation-request/{oe_translation_request}',
'collection' => '/admin/content/translation-request',
'edit-form' => '/translation-request/{oe_translation_request}/edit',
'delete-form' => '/translation-request/{oe_translation_request}/delete',
'delete-multiple-form' => '/admin/content/translation-requests/delete',
'preview' => "/translation-request/{oe_translation_request}/preview/{language}",
],
'bundle_entity_type' => 'oe_translation_request_type',
'field_ui_base_route' => 'entity.oe_translation_request_type.edit_form',
];
$translation_request_log_entity_type = [
'id' => 'oe_translation_request_log',
'label' => new TranslatableMarkup('Translation request log'),
'base_table' => 'oe_translation_request_log',
'entity_keys' => [
'id' => 'id',
'label' => 'id',
'uuid' => 'uuid',
'owner' => 'uid',
],
];
$translation_request_config_entity_type = [
'id' => 'oe_translation_request_type',
'label' => new TranslatableMarkup('Translation Request type'),
'handlers' => [
'form' => [
'add' => 'Drupal\oe_translation\Form\TranslationRequestTypeForm',
'edit' => 'Drupal\oe_translation\Form\TranslationRequestTypeForm',
'delete' => 'Drupal\Core\Entity\EntityDeleteForm',
],
'list_builder' => 'Drupal\oe_translation\TranslationRequestTypeListBuilder',
'route_provider' => [
'html' => 'Drupal\Core\Entity\Routing\AdminHtmlRouteProvider',
],
],
'admin_permission' => 'administer translation request types',
'bundle_of' => 'oe_translation_request',
'config_prefix' => 'oe_translation_request_type',
'entity_keys' => [
'id' => 'id',
'label' => 'label',
'uuid' => 'uuid',
],
'links' => [
'add-form' => '/admin/structure/oe_translation_request_types/add',
'edit-form' => '/admin/structure/oe_translation_request_types/manage/{oe_translation_request_type}',
'delete-form' => '/admin/structure/oe_translation_request_types/manage/{oe_translation_request_type}/delete',
'collection' => '/admin/structure/oe_translation_request_types',
],
'config_export' => [
'id',
'label',
'uuid',
],
];
$translation_request = new ContentEntityType($translation_request_entity_type);
$translation_request->setClass(TranslationRequest::class);
$update_manager->installEntityType($translation_request);
$translation_request_type = new ConfigEntityType($translation_request_config_entity_type);
$translation_request_type->setClass(TranslationRequestType::class);
$update_manager->installEntityType($translation_request_type);
$translation_request_log = new ContentEntityType($translation_request_log_entity_type);
$translation_request_log->setClass(TranslationRequestLog::class);
$update_manager->installEntityType($translation_request_log);
}