From a6916d7af32f6bab5d51c01cacf67d39846b1dea Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Thu, 29 Feb 2024 16:31:56 +0200 Subject: [PATCH 1/3] UHF-9440: Add new field information for the service channel migration --- migrations/tpr_service_channel.yml | 4 ++++ src/Entity/Channel.php | 1 + 2 files changed, 5 insertions(+) diff --git a/migrations/tpr_service_channel.yml b/migrations/tpr_service_channel.yml index 672494b6..4bdd3bc1 100644 --- a/migrations/tpr_service_channel.yml +++ b/migrations/tpr_service_channel.yml @@ -67,6 +67,10 @@ process: payment_enabled: payment_enabled for_personal_customer: for_personal_customer for_corporate_customer: for_corporate_customer + information/value: information + information/format: + plugin: default_value + default_value: plain_text destination: plugin: translatable_entity:tpr_service_channel default_values: diff --git a/src/Entity/Channel.php b/src/Entity/Channel.php index c55cf83b..2a3921c5 100644 --- a/src/Entity/Channel.php +++ b/src/Entity/Channel.php @@ -131,6 +131,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'expiration_time' => new TranslatableMarkup('Expiration time'), 'authorization_code' => new TranslatableMarkup('Information'), 'call_charge_info' => new TranslatableMarkup('Call charge info'), + 'information' => new TranslatableMarkup('Additional information'), ]; foreach ($text_fields as $name => $label) { $fields[$name] = BaseFieldDefinition::create('text_long') From b61bc6d9fb43e1918cfabfced7946a67051cb408 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 1 Mar 2024 11:15:08 +0200 Subject: [PATCH 2/3] UHF-9440: Update tests, install information field for the channel entity --- helfi_tpr.install | 20 ++++++++++++++++++- helfi_tpr.module | 2 +- .../helfi_address_search.module | 2 +- .../Field/FieldFormatter/KiloFormatter.php | 2 +- .../Plugin/views/area/AddressSearchInfo.php | 2 +- .../src/Plugin/views/field/DistanceField.php | 2 +- .../src/Plugin/views/filter/AddressSearch.php | 2 +- src/Entity/BaseFieldTrait.php | 2 +- src/Entity/Channel.php | 2 +- src/Entity/ChannelType.php | 2 +- src/Entity/ChannelTypeCollection.php | 2 +- src/Entity/DataFieldTrait.php | 2 +- src/Entity/ErrandService.php | 2 +- src/Entity/Form/ContentEntityForm.php | 2 +- src/Entity/Listing/ListBuilder.php | 2 +- src/Entity/OntologyWordDetails.php | 2 +- src/Entity/Service.php | 2 +- src/Entity/TprEntityBase.php | 2 +- src/Entity/TranslationHandler.php | 2 +- src/Entity/Unit.php | 2 +- .../MigrationConfigurationSubscriber.php | 2 +- src/Field/Connection/Connection.php | 2 +- src/Field/Connection/Highlight.php | 2 +- src/Field/Connection/Link.php | 2 +- src/Field/Connection/OpeningHour.php | 2 +- src/Field/Connection/OtherInfo.php | 2 +- src/Field/Connection/PhoneOrEmail.php | 2 +- src/Field/Connection/Price.php | 2 +- src/Field/Connection/Repository.php | 2 +- src/Field/Connection/Subgroup.php | 2 +- src/Field/Connection/Topical.php | 2 +- src/Field/FieldDefinition.php | 2 +- src/Fixture/ErrandService.php | 3 ++- src/Fixture/OntologyWordDetails.php | 2 +- src/Fixture/Service.php | 2 +- src/Fixture/Unit.php | 2 +- src/Plugin/DataType/ConnectionData.php | 2 +- .../AccessibilitySentenceFormatter.php | 2 +- .../ErrandServicesChannelFormatter.php | 2 +- .../OntologyWordDetailFormatter.php | 2 +- .../ServiceChannelFormatter.php | 2 +- .../FieldFormatter/ServiceMapFormatter.php | 2 +- .../FieldType/AccessibilitySentenceItem.php | 2 +- src/Plugin/Field/FieldType/ConnectionItem.php | 2 +- .../FieldType/OntologyWordDetailItem.php | 2 +- .../migrate/process/ArrayElementEquals.php | 2 +- src/Plugin/migrate/process/PublishByUnit.php | 2 +- .../migrate/source/OntologyWordDetails.php | 2 +- src/Plugin/migrate/source/ServiceChannel.php | 2 +- src/Plugin/migrate/source/ServiceMap.php | 2 +- src/Plugin/migrate/source/ServiceMapTrait.php | 2 +- src/Plugin/migrate/source/ServiceRegister.php | 2 +- src/Plugin/views/filter/ProvidedLanguages.php | 2 +- src/Plugin/views/filter/Status.php | 2 +- .../views/relationship/TagOwdRelationship.php | 2 +- src/TprViewsData.php | 2 +- .../src/Functional/ErrandServiceListTest.php | 2 +- tests/src/Functional/ListTestBase.php | 2 +- .../AccessibilitySentenceFormatterTest.php | 2 +- .../ConnectionFormatterTest.php | 2 +- .../CustomFieldFormatterTestBase.php | 2 +- .../ServiceChannelFormatterTest.php | 2 +- .../src/Functional/ServiceChannelListTest.php | 2 +- tests/src/Functional/ServiceListTest.php | 2 +- tests/src/Functional/ServiceMenuLinkTest.php | 2 +- tests/src/Functional/ServiceRevisionTest.php | 2 +- .../src/Functional/ServiceTranslationTest.php | 2 +- tests/src/Functional/UnitListTest.php | 2 +- tests/src/Functional/UnitMenuLinkTest.php | 2 +- tests/src/Functional/UnitRevisionTest.php | 2 +- tests/src/Functional/UnitTranslationTest.php | 2 +- tests/src/Kernel/ChannelEntityTest.php | 2 +- tests/src/Kernel/ErrandServiceEntityTest.php | 2 +- .../src/Kernel/ErrandServiceMigrationTest.php | 2 +- .../MigrationConfigurationSubscriberTest.php | 2 +- tests/src/Kernel/MigrationTestBase.php | 2 +- .../OntologyWordDetailsMigrationTest.php | 2 +- tests/src/Kernel/OntologyWordDetailsTest.php | 2 +- tests/src/Kernel/OverrideFieldTest.php | 2 +- .../AccessibilitySentenceItemTest.php | 2 +- .../Field/FieldType/ConnectionItemTest.php | 2 +- .../Kernel/ServiceChannelMigrationTest.php | 3 ++- tests/src/Kernel/ServiceEntityTest.php | 2 +- tests/src/Kernel/ServiceIdArgumentTest.php | 2 +- tests/src/Kernel/ServiceMigrationTest.php | 2 +- tests/src/Kernel/TokenTest.php | 2 +- tests/src/Kernel/UnitEntityTest.php | 2 +- tests/src/Kernel/UnitMigrationTest.php | 2 +- tests/src/Unit/ChannelTypeCollectionTest.php | 2 +- tests/src/Unit/ConnectionRepositoryTest.php | 2 +- tests/src/Unit/ConnectionTest.php | 2 +- .../ServiceMapFormatterTest.php | 2 +- .../process/ArrayElementEqualsTest.php | 2 +- 93 files changed, 113 insertions(+), 93 deletions(-) diff --git a/helfi_tpr.install b/helfi_tpr.install index 7f35cd58..7de212b4 100644 --- a/helfi_tpr.install +++ b/helfi_tpr.install @@ -5,7 +5,7 @@ * Contains helfi_tpr installation procedures. */ -declare(strict_types = 1); +declare(strict_types=1); use Drupal\content_translation\ContentTranslationHandler; use Drupal\Core\Field\BaseFieldDefinition; @@ -319,3 +319,21 @@ function helfi_tpr_update_8046() : void { \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('subgroup', 'tpr_unit', 'helfi_tpr', $subgroup_field); } + +/** + * UHF-9940 Add information text field to Channel entity. + */ +function helfi_tpr_update_8048() : void { + $field = BaseFieldDefinition::create('text_long') + ->setTranslatable(TRUE) + ->setRevisionable(FALSE) + ->setLabel(new TranslatableMarkup('Additional information')) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition('information', 'tpr_service_channel', 'helfi_tpr', $field); +} diff --git a/helfi_tpr.module b/helfi_tpr.module index b1327646..ffd19ba0 100644 --- a/helfi_tpr.module +++ b/helfi_tpr.module @@ -5,7 +5,7 @@ * Contains helfi_tpr. */ -declare(strict_types = 1); +declare(strict_types=1); use Drupal\Core\Access\AccessResult; use Drupal\Core\Database\Query\AlterableInterface; diff --git a/modules/helfi_address_search/helfi_address_search.module b/modules/helfi_address_search/helfi_address_search.module index 1bd81046..ac3fc9a7 100644 --- a/modules/helfi_address_search/helfi_address_search.module +++ b/modules/helfi_address_search/helfi_address_search.module @@ -5,7 +5,7 @@ * Contains helfi_address_search. */ -declare(strict_types = 1); +declare(strict_types=1); use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; diff --git a/modules/helfi_address_search/src/Plugin/Field/FieldFormatter/KiloFormatter.php b/modules/helfi_address_search/src/Plugin/Field/FieldFormatter/KiloFormatter.php index 8056f3db..5c2d1b33 100644 --- a/modules/helfi_address_search/src/Plugin/Field/FieldFormatter/KiloFormatter.php +++ b/modules/helfi_address_search/src/Plugin/Field/FieldFormatter/KiloFormatter.php @@ -1,6 +1,6 @@ sprintf('%s.email.%s.%s@hel.fi', $id, $language, $channelId), 'phone' => sprintf('%s-123456-%s-%s', $id, $language, $channelId), 'call_charge_info' => sprintf('call_charge_info %s %s %s', $id, $language, $channelId), + 'information' => sprintf('information %s %s %s', $id, $language, $channelId), 'availabilities' => [ [ 'availability_string' => sprintf('0:%s:test %s %s', $id, $language, $channelId), diff --git a/src/Fixture/OntologyWordDetails.php b/src/Fixture/OntologyWordDetails.php index 9e2b6989..eeba3cfd 100644 --- a/src/Fixture/OntologyWordDetails.php +++ b/src/Fixture/OntologyWordDetails.php @@ -1,6 +1,6 @@ new FormattableMarkup('@id.email.@langcode.@tid@hel.fi', $args), 'phone' => new FormattableMarkup('@id-123456-@langcode-@tid', $args), 'call_charge_info' => new FormattableMarkup('call_charge_info @id @langcode @tid', $args), + 'information' => new FormattableMarkup('information @id @langcode @tid', $args), 'type' => 'EMAIL', 'requires_authentication' => TRUE, 'saved_to_customer_folder' => TRUE, diff --git a/tests/src/Kernel/ServiceEntityTest.php b/tests/src/Kernel/ServiceEntityTest.php index 2b09bc0b..c2cbee7f 100644 --- a/tests/src/Kernel/ServiceEntityTest.php +++ b/tests/src/Kernel/ServiceEntityTest.php @@ -1,6 +1,6 @@ Date: Fri, 1 Mar 2024 14:03:08 +0200 Subject: [PATCH 3/3] UHF-9440: Change the update number to correct --- helfi_tpr.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helfi_tpr.install b/helfi_tpr.install index 7de212b4..a3f7233d 100644 --- a/helfi_tpr.install +++ b/helfi_tpr.install @@ -323,7 +323,7 @@ function helfi_tpr_update_8046() : void { /** * UHF-9940 Add information text field to Channel entity. */ -function helfi_tpr_update_8048() : void { +function helfi_tpr_update_8047() : void { $field = BaseFieldDefinition::create('text_long') ->setTranslatable(TRUE) ->setRevisionable(FALSE)