From cf44260351790758138cef593269afcf94fd5d95 Mon Sep 17 00:00:00 2001 From: mmyllynen <4696381+dire@users.noreply.github.com> Date: Mon, 19 Jun 2023 08:27:19 +0300 Subject: [PATCH 1/5] UFH-8595: UHF-8595: Added multiple missing fields to Units. --- helfi_tpr.install | 54 ++++++++++++++++++++++ migrations/tpr_unit.yml | 48 ++++++++++++++++++++ src/Entity/Unit.php | 34 ++++++++++++++ src/Field/Connection/Link.php | 65 +++++++++++++++++++++++++++ src/Field/Connection/OtherInfo.php | 47 +++++++++++++++++++ src/Field/Connection/PhoneOrEmail.php | 59 ++++++++++++++++++++++++ src/Field/Connection/Price.php | 47 +++++++++++++++++++ src/Field/Connection/Repository.php | 4 ++ translations/fi.po | 12 +++++ translations/sv.po | 12 +++++ 10 files changed, 382 insertions(+) create mode 100644 src/Field/Connection/Link.php create mode 100644 src/Field/Connection/OtherInfo.php create mode 100644 src/Field/Connection/PhoneOrEmail.php create mode 100644 src/Field/Connection/Price.php diff --git a/helfi_tpr.install b/helfi_tpr.install index 88b026c..6e01253 100644 --- a/helfi_tpr.install +++ b/helfi_tpr.install @@ -227,3 +227,57 @@ function helfi_tpr_update_8043() : void { ->installFieldStorageDefinition($name, 'tpr_service', 'helfi_tpr', $field); } } + +/** + * Add multiple missing fields to Unit entity. + */ +function helfi_tpr_update_8044() : void { + $fields['other_info'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Further information')) + ->setDescription(new TranslatableMarkup('The "OTHER_INFO" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + $fields['price_info'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Charges')) + ->setDescription(new TranslatableMarkup('The "PRICE" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + $fields['links'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Web sites')) + ->setDescription(new TranslatableMarkup('The "LINK" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + $fields['contacts'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Other contact information')) + ->setDescription(new TranslatableMarkup('The "PHONE_OR_EMAIL" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + foreach ($fields as $name => $field) { + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition($name, 'tpr_unit', 'helfi_tpr', $field); + } +} diff --git a/migrations/tpr_unit.yml b/migrations/tpr_unit.yml index 753d1fb..d996aba 100644 --- a/migrations/tpr_unit.yml +++ b/migrations/tpr_unit.yml @@ -56,6 +56,54 @@ process: value: value data: data type: type + _other_info_connections: + plugin: array_element_equals + source: connections + value: OTHER_INFO + key: type + other_info: + plugin: sub_process + source: '@_other_info_connections' + process: + value: value + data: data + type: type + _price_info_connections: + plugin: array_element_equals + source: connections + value: PRICE + key: type + price_info: + plugin: sub_process + source: '@_price_info_connections' + process: + value: value + data: data + type: type + _links_connections: + plugin: array_element_equals + source: connections + value: LINK + key: type + links: + plugin: sub_process + source: '@_links_connections' + process: + value: value + data: data + type: type + _contacts_connections: + plugin: array_element_equals + source: connections + value: PHONE_OR_EMAIL + key: type + contacts: + plugin: sub_process + source: '@_contacts_connections' + process: + value: value + data: data + type: type accessibility_sentences: plugin: sub_process source: accessibility_sentences diff --git a/src/Entity/Unit.php b/src/Entity/Unit.php index f93f9b2..38f891a 100644 --- a/src/Entity/Unit.php +++ b/src/Entity/Unit.php @@ -336,6 +336,40 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) : ->setDisplayOptions('form', [ 'region' => 'hidden', ]); + $fields['other_info'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Further information')) + ->setDescription(new TranslatableMarkup('The "OTHER_INFO" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + $fields['price_info'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Charges')) + ->setDescription(new TranslatableMarkup('The "PRICE" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + $fields['links'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Web sites')) + ->setDescription(new TranslatableMarkup('The "LINK" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + $fields['contacts'] = BaseFieldDefinition::create('tpr_connection') + ->setLabel(new TranslatableMarkup('Other contact information')) + ->setDescription(new TranslatableMarkup('The "PHONE_OR_EMAIL" connection type')) + ->setTranslatable(TRUE) + ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); return $fields; } diff --git a/src/Field/Connection/Link.php b/src/Field/Connection/Link.php new file mode 100644 index 0000000..b68e504 --- /dev/null +++ b/src/Field/Connection/Link.php @@ -0,0 +1,65 @@ +get('name')); + + if (function_exists('_filter_autop')) { + $markup = _filter_autop($markup); + } + + $build = [ + 'name' => [ + '#markup' => $markup, + ], + ]; + + if ($link = $this->get('www')) { + try { + return [ + 'www' => [ + '#title' => $this->get('name'), + '#type' => 'link', + '#url' => Url::fromUri($link), + ], + ]; + } + catch (\InvalidArgumentException) { + } + } + + return $build; + } + +} diff --git a/src/Field/Connection/OtherInfo.php b/src/Field/Connection/OtherInfo.php new file mode 100644 index 0000000..76c883e --- /dev/null +++ b/src/Field/Connection/OtherInfo.php @@ -0,0 +1,47 @@ +get('name')); + + if (function_exists('_filter_autop')) { + $markup = _filter_autop($markup); + } + + return [ + 'name' => [ + '#markup' => $markup, + ], + ]; + } + +} diff --git a/src/Field/Connection/PhoneOrEmail.php b/src/Field/Connection/PhoneOrEmail.php new file mode 100644 index 0000000..3fd2d1a --- /dev/null +++ b/src/Field/Connection/PhoneOrEmail.php @@ -0,0 +1,59 @@ +getFields(); + $fields_data = []; + + foreach ($fields as $field) { + if (!$this->get($field)) { + continue; + } + + $data = Html::escape($this->get($field)); + + $fields_data[] = $data; + } + + $build = [ + 'contact' => [ + '#markup' => '

' . implode('
', $fields_data) . '

', + ], + ]; + + return $build; + } + +} diff --git a/src/Field/Connection/Price.php b/src/Field/Connection/Price.php new file mode 100644 index 0000000..1652c0a --- /dev/null +++ b/src/Field/Connection/Price.php @@ -0,0 +1,47 @@ +get('name')); + + if (function_exists('_filter_autop')) { + $markup = _filter_autop($markup); + } + + return [ + 'name' => [ + '#markup' => $markup, + ], + ]; + } + +} diff --git a/src/Field/Connection/Repository.php b/src/Field/Connection/Repository.php index beffcca..13a6d45 100644 --- a/src/Field/Connection/Repository.php +++ b/src/Field/Connection/Repository.php @@ -18,6 +18,10 @@ final class Repository { OpeningHour::TYPE_NAME => OpeningHour::class, OpeningHourObject::TYPE_NAME => OpeningHourObject::class, Highlight::TYPE_NAME => Highlight::class, + OtherInfo::TYPE_NAME => OtherInfo::class, + Price::TYPE_NAME => Price::class, + Link::TYPE_NAME => Link::class, + PhoneOrEmail::TYPE_NAME => PhoneOrEmail::class, ]; /** diff --git a/translations/fi.po b/translations/fi.po index 657d4b6..b468aae 100644 --- a/translations/fi.po +++ b/translations/fi.po @@ -55,3 +55,15 @@ msgstr "Ylikirjoita arvo kentälle: @field_name" msgid "Override: Picture" msgstr "Oletuskuvan korvaava kuva" + +msgid "Further information" +msgstr "Lisätietoja" + +msgid "Charges" +msgstr "Hinnat" + +msgid "Web sites" +msgstr "Muualla verkossa" + +msgid "Other contact information" +msgstr "Muut yhteystiedot" diff --git a/translations/sv.po b/translations/sv.po index c8d38db..da8f6d6 100644 --- a/translations/sv.po +++ b/translations/sv.po @@ -40,3 +40,15 @@ msgstr "Överskrida: @field_name" msgid "Override: Picture" msgstr "Bild som ersätter standardbilden" + +msgid "Further information" +msgstr "Ytterligare uppgifter" + +msgid "Charges" +msgstr "Priser" + +msgid "Web sites" +msgstr "På webben" + +msgid "Other contact information" +msgstr "Andra kontaktuppgifter" From 82149dda02f3a207d42aaaa2ebefc50d64adbfde Mon Sep 17 00:00:00 2001 From: mmyllynen <4696381+dire@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:14:01 +0300 Subject: [PATCH 2/5] UFH-8595: Set the display options for rest of the new fields too. --- src/Entity/Unit.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Entity/Unit.php b/src/Entity/Unit.php index 38f891a..64b6a51 100644 --- a/src/Entity/Unit.php +++ b/src/Entity/Unit.php @@ -342,14 +342,20 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) : ->setTranslatable(TRUE) ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ->setDisplayConfigurable('form', TRUE) - ->setDisplayConfigurable('view', TRUE); + ->setDisplayConfigurable('view', TRUE) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]); $fields['price_info'] = BaseFieldDefinition::create('tpr_connection') ->setLabel(new TranslatableMarkup('Charges')) ->setDescription(new TranslatableMarkup('The "PRICE" connection type')) ->setTranslatable(TRUE) ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ->setDisplayConfigurable('form', TRUE) - ->setDisplayConfigurable('view', TRUE); + ->setDisplayConfigurable('view', TRUE) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]); $fields['links'] = BaseFieldDefinition::create('tpr_connection') ->setLabel(new TranslatableMarkup('Web sites')) ->setDescription(new TranslatableMarkup('The "LINK" connection type')) From 3873f5c491d3fc6729bb08c044ef49bd2bfcd017 Mon Sep 17 00:00:00 2001 From: tuutti Date: Thu, 22 Jun 2023 10:13:57 +0300 Subject: [PATCH 3/5] UFH-8595: Set correct parent so values are not removed when the form is saved --- src/Entity/Unit.php | 8 ++++++++ src/Plugin/Field/FieldFormatter/ConnectionFormatter.php | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Entity/Unit.php b/src/Entity/Unit.php index 64b6a51..0f2332d 100644 --- a/src/Entity/Unit.php +++ b/src/Entity/Unit.php @@ -301,6 +301,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) : ->setDescription(new TranslatableMarkup('The "OPENING_HOURS" connection type')) ->setTranslatable(TRUE) ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); $fields['provided_languages'] = BaseFieldDefinition::create('string') ->setLabel(new TranslatableMarkup('Provided languages')) @@ -323,6 +327,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) : ->setLabel(new TranslatableMarkup('Highlights')) ->setTranslatable(TRUE) ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) + ->setDisplayOptions('form', [ + 'type' => 'readonly_field_widget', + ]) + ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); $fields['ontologyword_ids'] = BaseFieldDefinition::create('integer') ->setLabel(new TranslatableMarkup('Ontologyword IDs')) diff --git a/src/Plugin/Field/FieldFormatter/ConnectionFormatter.php b/src/Plugin/Field/FieldFormatter/ConnectionFormatter.php index 3ce49bc..0cb845b 100644 --- a/src/Plugin/Field/FieldFormatter/ConnectionFormatter.php +++ b/src/Plugin/Field/FieldFormatter/ConnectionFormatter.php @@ -32,6 +32,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) : array { $element[$delta] = [ '#type' => 'item', 'content' => $item->data->build(), + '#parents' => [$delta], ]; } From b0dd53c7c80729a625e97d41831fba8ebb62e6ab Mon Sep 17 00:00:00 2001 From: mmyllynen <4696381+dire@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:25:59 +0300 Subject: [PATCH 4/5] UFH-8595: Renamed OpeningHourBase and some refactoring. --- src/Entity/Listing/ListBuilder.php | 2 +- src/Field/Connection/Link.php | 48 +------------------ src/Field/Connection/OpeningHour.php | 2 +- src/Field/Connection/OpeningHourObject.php | 2 +- ...eningHourBase.php => TextWithLinkBase.php} | 4 +- tests/src/Unit/ConnectionTest.php | 16 +++---- 6 files changed, 14 insertions(+), 60 deletions(-) rename src/Field/Connection/{OpeningHourBase.php => TextWithLinkBase.php} (89%) diff --git a/src/Entity/Listing/ListBuilder.php b/src/Entity/Listing/ListBuilder.php index 53c4e84..541f7ec 100644 --- a/src/Entity/Listing/ListBuilder.php +++ b/src/Entity/Listing/ListBuilder.php @@ -4,9 +4,9 @@ namespace Drupal\helfi_tpr\Entity\Listing; +use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; -use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Routing\RedirectDestinationInterface; diff --git a/src/Field/Connection/Link.php b/src/Field/Connection/Link.php index b68e504..4e4b06b 100644 --- a/src/Field/Connection/Link.php +++ b/src/Field/Connection/Link.php @@ -4,13 +4,10 @@ namespace Drupal\helfi_tpr\Field\Connection; -use Drupal\Component\Utility\Html; -use Drupal\Core\Url; - /** * Provides a domain object for TPR connection type of LINK. */ -final class Link extends Connection { +final class Link extends TextWithLinkBase { /** * The type name. @@ -19,47 +16,4 @@ final class Link extends Connection { */ public const TYPE_NAME = 'LINK'; - /** - * {@inheritdoc} - */ - public function getFields(): array { - return [ - 'name', - 'www', - ]; - } - - /** - * {@inheritdoc} - */ - public function build(): array { - $markup = Html::escape($this->get('name')); - - if (function_exists('_filter_autop')) { - $markup = _filter_autop($markup); - } - - $build = [ - 'name' => [ - '#markup' => $markup, - ], - ]; - - if ($link = $this->get('www')) { - try { - return [ - 'www' => [ - '#title' => $this->get('name'), - '#type' => 'link', - '#url' => Url::fromUri($link), - ], - ]; - } - catch (\InvalidArgumentException) { - } - } - - return $build; - } - } diff --git a/src/Field/Connection/OpeningHour.php b/src/Field/Connection/OpeningHour.php index cd89679..bf3c3f5 100644 --- a/src/Field/Connection/OpeningHour.php +++ b/src/Field/Connection/OpeningHour.php @@ -7,7 +7,7 @@ /** * Provides a DTO for TPR connection type of OPENING_HOURS. */ -final class OpeningHour extends OpeningHourBase { +final class OpeningHour extends TextWithLinkBase { /** * The type name. diff --git a/src/Field/Connection/OpeningHourObject.php b/src/Field/Connection/OpeningHourObject.php index 6e84f8c..b8f6d34 100644 --- a/src/Field/Connection/OpeningHourObject.php +++ b/src/Field/Connection/OpeningHourObject.php @@ -7,7 +7,7 @@ /** * Provides a DTO for TPR connection type of OPENING_HOUR_OBJECT. */ -final class OpeningHourObject extends OpeningHourBase { +final class OpeningHourObject extends TextWithLinkBase { /** * The type name. diff --git a/src/Field/Connection/OpeningHourBase.php b/src/Field/Connection/TextWithLinkBase.php similarity index 89% rename from src/Field/Connection/OpeningHourBase.php rename to src/Field/Connection/TextWithLinkBase.php index d0fc59e..c478fd0 100644 --- a/src/Field/Connection/OpeningHourBase.php +++ b/src/Field/Connection/TextWithLinkBase.php @@ -8,9 +8,9 @@ use Drupal\Core\Url; /** - * A base class for 'opening hour' connections. + * A base class for connections with text and link. */ -abstract class OpeningHourBase extends Connection { +abstract class TextWithLinkBase extends Connection { /** * {@inheritdoc} diff --git a/tests/src/Unit/ConnectionTest.php b/tests/src/Unit/ConnectionTest.php index 3a0750a..59faaa2 100644 --- a/tests/src/Unit/ConnectionTest.php +++ b/tests/src/Unit/ConnectionTest.php @@ -6,7 +6,7 @@ use Drupal\helfi_tpr\Field\Connection\Highlight; use Drupal\helfi_tpr\Field\Connection\OpeningHour; -use Drupal\helfi_tpr\Field\Connection\OpeningHourBase; +use Drupal\helfi_tpr\Field\Connection\TextWithLinkBase; use Drupal\helfi_tpr\Field\Connection\OpeningHourObject; use Drupal\Tests\UnitTestCase; @@ -21,14 +21,14 @@ class ConnectionTest extends UnitTestCase { /** * Tests opening hours. * - * @covers \Drupal\helfi_tpr\Field\Connection\OpeningHourBase::build - * @covers \Drupal\helfi_tpr\Field\Connection\OpeningHourBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::build + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields * @covers ::set * @covers ::get * @covers ::isValidField * @dataProvider openingHourData */ - public function testOpeningHours(OpeningHourBase $object) : void { + public function testOpeningHours(TextWithLinkBase $object) : void { $object->set('name', 'mon-wed 10-19'); $this->assertNotEmpty($object->build()); @@ -71,10 +71,10 @@ public function testHighlights() : void { * * @covers ::set * @covers ::isValidField - * @covers \Drupal\helfi_tpr\Field\Connection\OpeningHourBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields * @dataProvider openingHourData */ - public function testInvalidFieldName(OpeningHourBase $object) : void { + public function testInvalidFieldName(TextWithLinkBase $object) : void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Field "invalid_field" is not valid.'); $object->set('invalid_field', 'value'); @@ -97,7 +97,7 @@ public function openingHourData() : array { * Tests invalid data type. * * @dataProvider invalidFieldValueData - * @covers \Drupal\helfi_tpr\Field\Connection\OpeningHourBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields * @covers ::set * @covers ::isValidField */ @@ -125,7 +125,7 @@ public function invalidFieldValueData() : array { * Tests valid values. * * @dataProvider validFieldValueData - * @covers \Drupal\helfi_tpr\Field\Connection\OpeningHourBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields * @covers ::set * @covers ::get * @covers ::isValidField From acd8475b8457185109a4b1ef85dfb183af8e8b9c Mon Sep 17 00:00:00 2001 From: mmyllynen <4696381+dire@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:41:04 +0300 Subject: [PATCH 5/5] UFH-8595: Little name tweaks. --- src/Field/Connection/Link.php | 2 +- src/Field/Connection/OpeningHour.php | 2 +- src/Field/Connection/OpeningHourObject.php | 2 +- .../{TextWithLinkBase.php => TextWithLink.php} | 2 +- tests/src/Unit/ConnectionTest.php | 16 ++++++++-------- 5 files changed, 12 insertions(+), 12 deletions(-) rename src/Field/Connection/{TextWithLinkBase.php => TextWithLink.php} (94%) diff --git a/src/Field/Connection/Link.php b/src/Field/Connection/Link.php index 4e4b06b..a0384e0 100644 --- a/src/Field/Connection/Link.php +++ b/src/Field/Connection/Link.php @@ -7,7 +7,7 @@ /** * Provides a domain object for TPR connection type of LINK. */ -final class Link extends TextWithLinkBase { +final class Link extends TextWithLink { /** * The type name. diff --git a/src/Field/Connection/OpeningHour.php b/src/Field/Connection/OpeningHour.php index bf3c3f5..0e0e736 100644 --- a/src/Field/Connection/OpeningHour.php +++ b/src/Field/Connection/OpeningHour.php @@ -7,7 +7,7 @@ /** * Provides a DTO for TPR connection type of OPENING_HOURS. */ -final class OpeningHour extends TextWithLinkBase { +final class OpeningHour extends TextWithLink { /** * The type name. diff --git a/src/Field/Connection/OpeningHourObject.php b/src/Field/Connection/OpeningHourObject.php index b8f6d34..01de269 100644 --- a/src/Field/Connection/OpeningHourObject.php +++ b/src/Field/Connection/OpeningHourObject.php @@ -7,7 +7,7 @@ /** * Provides a DTO for TPR connection type of OPENING_HOUR_OBJECT. */ -final class OpeningHourObject extends TextWithLinkBase { +final class OpeningHourObject extends TextWithLink { /** * The type name. diff --git a/src/Field/Connection/TextWithLinkBase.php b/src/Field/Connection/TextWithLink.php similarity index 94% rename from src/Field/Connection/TextWithLinkBase.php rename to src/Field/Connection/TextWithLink.php index c478fd0..5740f80 100644 --- a/src/Field/Connection/TextWithLinkBase.php +++ b/src/Field/Connection/TextWithLink.php @@ -10,7 +10,7 @@ /** * A base class for connections with text and link. */ -abstract class TextWithLinkBase extends Connection { +abstract class TextWithLink extends Connection { /** * {@inheritdoc} diff --git a/tests/src/Unit/ConnectionTest.php b/tests/src/Unit/ConnectionTest.php index 59faaa2..1fd6035 100644 --- a/tests/src/Unit/ConnectionTest.php +++ b/tests/src/Unit/ConnectionTest.php @@ -6,8 +6,8 @@ use Drupal\helfi_tpr\Field\Connection\Highlight; use Drupal\helfi_tpr\Field\Connection\OpeningHour; -use Drupal\helfi_tpr\Field\Connection\TextWithLinkBase; use Drupal\helfi_tpr\Field\Connection\OpeningHourObject; +use Drupal\helfi_tpr\Field\Connection\TextWithLink; use Drupal\Tests\UnitTestCase; /** @@ -21,14 +21,14 @@ class ConnectionTest extends UnitTestCase { /** * Tests opening hours. * - * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::build - * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLink::build + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLink::getFields * @covers ::set * @covers ::get * @covers ::isValidField * @dataProvider openingHourData */ - public function testOpeningHours(TextWithLinkBase $object) : void { + public function testOpeningHours(TextWithLink $object) : void { $object->set('name', 'mon-wed 10-19'); $this->assertNotEmpty($object->build()); @@ -71,10 +71,10 @@ public function testHighlights() : void { * * @covers ::set * @covers ::isValidField - * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLink::getFields * @dataProvider openingHourData */ - public function testInvalidFieldName(TextWithLinkBase $object) : void { + public function testInvalidFieldName(TextWithLink $object) : void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Field "invalid_field" is not valid.'); $object->set('invalid_field', 'value'); @@ -97,7 +97,7 @@ public function openingHourData() : array { * Tests invalid data type. * * @dataProvider invalidFieldValueData - * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLink::getFields * @covers ::set * @covers ::isValidField */ @@ -125,7 +125,7 @@ public function invalidFieldValueData() : array { * Tests valid values. * * @dataProvider validFieldValueData - * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLinkBase::getFields + * @covers \Drupal\helfi_tpr\Field\Connection\TextWithLink::getFields * @covers ::set * @covers ::get * @covers ::isValidField