2020-02-22 14:10:46 +00:00
|
|
|
<?php
|
|
|
|
|
2020-06-08 13:21:16 +00:00
|
|
|
|
|
|
|
use \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchemaConverter;
|
2021-06-15 17:55:45 +00:00
|
|
|
use \Drupal\Core\Field\BaseFieldDefinition;
|
|
|
|
|
2021-07-16 15:32:40 +00:00
|
|
|
function opencase_entities_update_80202() {
|
|
|
|
\Drupal::entityTypeManager()->clearCachedDefinitions();
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_organisation_relation'));
|
|
|
|
}
|
|
|
|
|
2021-06-29 07:21:04 +00:00
|
|
|
function opencase_entities_update_80201() {
|
|
|
|
$update_manager = \Drupal::entityDefinitionUpdateManager();
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('phone', 'oc_actor');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('phone2', 'oc_actor');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('postal_address', 'oc_actor');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('email', 'oc_actor');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('post_code', 'oc_actor');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
}
|
|
|
|
|
2021-06-15 18:13:42 +00:00
|
|
|
function opencase_entities_update_80200() {
|
|
|
|
$field_storage_definition = BaseFieldDefinition::create('string')
|
|
|
|
->setLabel(t('Website'))
|
|
|
|
->setRevisionable(TRUE)
|
|
|
|
->setSettings([
|
|
|
|
'max_length' => 50,
|
|
|
|
'text_processing' => 0,
|
|
|
|
])
|
|
|
|
->setDefaultValue('')
|
|
|
|
->setDisplayOptions('view', [
|
|
|
|
'label' => 'above',
|
|
|
|
'type' => 'string',
|
|
|
|
'weight' => 49,
|
|
|
|
])
|
|
|
|
->setDisplayOptions('form', [
|
|
|
|
'type' => 'string_textfield',
|
|
|
|
'weight' => 49,
|
|
|
|
])
|
|
|
|
->setRequired(FALSE);
|
|
|
|
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installFieldStorageDefinition('org_website', 'oc_organisation', 'opencase_entities', $field_storage_definition);
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:55:45 +00:00
|
|
|
function opencase_entities_update_80199() {
|
|
|
|
$field_storage_definition = BaseFieldDefinition::create('string')
|
|
|
|
->setLabel(t('Contact Role'))
|
|
|
|
->setDescription(t('Role of the contact within the organisation'))
|
|
|
|
->setRevisionable(TRUE)
|
|
|
|
->setSettings([
|
|
|
|
'max_length' => 50,
|
|
|
|
'text_processing' => 0,
|
|
|
|
])
|
|
|
|
->setDefaultValue('')
|
|
|
|
->setDisplayOptions('view', [
|
|
|
|
'label' => 'above',
|
|
|
|
'type' => 'string',
|
|
|
|
'weight' => 52,
|
|
|
|
])
|
|
|
|
->setDisplayOptions('form', [
|
|
|
|
'type' => 'string_textfield',
|
|
|
|
'weight' => 52,
|
|
|
|
])
|
|
|
|
->setRequired(FALSE);
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installFieldStorageDefinition('contact_role', 'oc_organisation', 'opencase_entities', $field_storage_definition);
|
|
|
|
}
|
2020-06-08 13:21:16 +00:00
|
|
|
|
2021-01-19 14:55:18 +00:00
|
|
|
function opencase_entities_update_80198() {
|
|
|
|
$field_storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('file')
|
|
|
|
->setLabel(t('Files'))
|
|
|
|
->setDescription(t('Files relating to this organisation'))
|
|
|
|
->setSetting('file_directory', '[date:custom:Y]-[date:custom:m]')
|
|
|
|
->setSetting('handler', 'default:file')
|
|
|
|
->setSetting('file_extensions', 'txt jpg jpeg gif rtf xls xlsx doc swf png pdf docx csv')
|
|
|
|
->setSetting('description_field', 'true')
|
|
|
|
->setSetting('uri_scheme', 'private')
|
|
|
|
->setCardinality(-1)
|
|
|
|
->setDisplayOptions('form', [
|
|
|
|
'type' => 'file_generic',
|
|
|
|
'weight' => 61,
|
|
|
|
'settings' => [
|
|
|
|
'progress_indicator' => 'throbber',
|
|
|
|
],
|
|
|
|
])
|
|
|
|
->setDisplayOptions('view', [
|
|
|
|
'label' => 'above',
|
|
|
|
'settings' => ['use_description_as_link_text' => 'true']
|
|
|
|
]);
|
|
|
|
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installFieldStorageDefinition('organisation_files', 'oc_organisation', 'opencase_entities', $field_storage_definition);
|
|
|
|
}
|
|
|
|
|
2020-11-15 17:39:50 +00:00
|
|
|
function opencase_entities_update_80197() {
|
|
|
|
//check if the table exists first. If not, then create the entity.
|
|
|
|
if(!db_table_exists('oc_organisation')) {
|
|
|
|
\Drupal::entityTypeManager()->clearCachedDefinitions();
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installEntityType(\Drupal::entityTypeManager()->getDefinition('oc_organisation'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 'Organisation entity already exists';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 13:21:16 +00:00
|
|
|
function opencase_entities_update_80192(&$sandbox) {
|
|
|
|
$schema_converter = new SqlContentEntityStorageSchemaConverter(
|
|
|
|
'oc_actor',
|
|
|
|
\Drupal::entityTypeManager(),
|
|
|
|
\Drupal::entityDefinitionUpdateManager(),
|
|
|
|
\Drupal::service('entity.last_installed_schema.repository'),
|
|
|
|
\Drupal::keyValue('entity.storage_schema.sql'),
|
|
|
|
\Drupal::database()
|
|
|
|
);
|
|
|
|
|
|
|
|
$contact_details_fields = ['email', 'phone', 'phone2', 'postal_address', 'post_code'];
|
|
|
|
$schema_converter->convertToRevisionable($sandbox, $contact_details_fields);
|
|
|
|
}
|
|
|
|
|
2020-03-01 09:42:06 +00:00
|
|
|
function opencase_entities_update_8016() {
|
|
|
|
$update_manager = \Drupal::entityDefinitionUpdateManager();
|
|
|
|
$definition = $update_manager->getFieldStorageDefinition('activity_date_time', 'oc_activity');
|
|
|
|
$update_manager->updateFieldStorageDefinition($definition);
|
|
|
|
}
|
|
|
|
|
2020-02-22 14:10:46 +00:00
|
|
|
/**
|
|
|
|
* Add 'activity_date_time' field to 'oc_activity' entities.
|
|
|
|
*/
|
|
|
|
function opencase_entities_update_8003() {
|
|
|
|
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
|
|
|
|
->setLabel(t('Date and time'))
|
|
|
|
->setRevisionable(TRUE)
|
2020-02-24 17:09:57 +00:00
|
|
|
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
|
2020-02-22 14:10:46 +00:00
|
|
|
->setDisplayOptions('view', [
|
|
|
|
'type' => 'datetime_default',
|
|
|
|
'settings' => [
|
|
|
|
'format_type' => 'medium',
|
|
|
|
],
|
|
|
|
'label' => 'above',
|
|
|
|
'weight' => -3,
|
|
|
|
])
|
|
|
|
->setDisplayOptions('form', [
|
|
|
|
'type' => 'datetime_default',
|
|
|
|
'weight' => -3,
|
|
|
|
]);
|
|
|
|
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installFieldStorageDefinition('activity_date_time', 'oc_activity', 'oc_activity', $storage_definition);
|
|
|
|
}
|