-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from City-of-Helsinki/UHF-212_service
UHF-212: Service integration
- Loading branch information
Showing
18 changed files
with
620 additions
and
106 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
config/install/language.content_settings.tpr_service.tpr_service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- content_translation | ||
- helfi_tpr | ||
third_party_settings: | ||
content_translation: | ||
enabled: true | ||
bundle_settings: | ||
untranslatable_fields_hide: '0' | ||
id: tpr_service.tpr_service | ||
target_entity_type_id: tpr_service | ||
target_bundle: tpr_service | ||
default_langcode: site_default | ||
language_alterable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains helfi_tpr installation procedures. | ||
*/ | ||
|
||
use Drupal\Core\Field\BaseFieldDefinition; | ||
use Drupal\Core\StringTranslation\TranslatableMarkup; | ||
|
||
/** | ||
* Installs the service entity type. | ||
*/ | ||
function helfi_tpr_update_8001() : void { | ||
$manager = \Drupal::entityDefinitionUpdateManager(); | ||
$entity_type = \Drupal::entityTypeManager()->getDefinition('tpr_service'); | ||
$manager->installEntityType($entity_type); | ||
} | ||
|
||
/** | ||
* Install TPR service description field. | ||
*/ | ||
function helfi_tpr_update_8002() : void { | ||
$manager = \Drupal::entityDefinitionUpdateManager(); | ||
$fields = []; | ||
$fields['description'] = BaseFieldDefinition::create('text_with_summary') | ||
->setTranslatable(TRUE) | ||
->setLabel(new TranslatableMarkup('Description')) | ||
->setDisplayConfigurable('form', TRUE) | ||
->setDisplayConfigurable('view', TRUE); | ||
|
||
foreach ($fields as $name => $field) { | ||
$manager->installFieldStorageDefinition($name, 'tpr_service', 'helfi_tpr', $field); | ||
} | ||
} | ||
|
||
/** | ||
* Install TPR unit service reference field. | ||
*/ | ||
function helfi_tpr_update_8003() : void { | ||
$manager = \Drupal::entityDefinitionUpdateManager(); | ||
$fields = []; | ||
$fields['services'] = BaseFieldDefinition::create('entity_reference') | ||
->setLabel(new TranslatableMarkup('Services')) | ||
->setSettings([ | ||
'target_type' => 'tpr_service', | ||
'handler_settings' => [ | ||
'target_bundles' => ['tpr_service'], | ||
], | ||
]) | ||
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) | ||
->setDisplayConfigurable('view', TRUE) | ||
->setDisplayConfigurable('form', TRUE); | ||
|
||
foreach ($fields as $name => $field) { | ||
$manager->installFieldStorageDefinition($name, 'tpr_unit', 'helfi_tpr', $field); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
enforced: | ||
module: | ||
- helfi_tpr | ||
id: tpr_service | ||
migration_tags: | ||
- tpr | ||
label: 'TPR service' | ||
source: | ||
plugin: tpr_service_register | ||
track_changes: true | ||
url: 'http://www.hel.fi/palvelukarttaws/rest/vpalvelurekisteri/description/' | ||
ids: | ||
id: | ||
type: string | ||
process: | ||
id: id | ||
destination: | ||
plugin: tpr_service | ||
migration_dependencies: | ||
required: | ||
- tpr_unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\helfi_tpr\Entity; | ||
|
||
use Drupal\Core\Entity\EntityTypeInterface; | ||
use Drupal\Core\Field\BaseFieldDefinition; | ||
use Drupal\Core\StringTranslation\TranslatableMarkup; | ||
|
||
/** | ||
* Defines the tpr_service entity class. | ||
* | ||
* @ContentEntityType( | ||
* id = "tpr_service", | ||
* label = @Translation("TPR - Service"), | ||
* label_collection = @Translation("TPR - Service"), | ||
* handlers = { | ||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", | ||
* "list_builder" = "Drupal\helfi_tpr\Entity\Listing\ListBuilder", | ||
* "views_data" = "Drupal\views\EntityViewsData", | ||
* "access" = "Drupal\helfi_api_base\Entity\Access\RemoteEntityAccess", | ||
* "form" = { | ||
* "default" = "Drupal\Core\Entity\ContentEntityForm", | ||
* "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm" | ||
* }, | ||
* "route_provider" = { | ||
* "html" = "Drupal\helfi_api_base\Entity\Routing\EntityRouteProvider", | ||
* }, | ||
* }, | ||
* base_table = "tpr_service", | ||
* data_table = "tpr_service_field_data", | ||
* revision_table = "tpr_service_revision", | ||
* revision_data_table = "tpr_service_field_revision", | ||
* show_revision_ui = TRUE, | ||
* translatable = TRUE, | ||
* admin_permission = "administer remote entities", | ||
* entity_keys = { | ||
* "id" = "id", | ||
* "revision" = "revision_id", | ||
* "langcode" = "langcode", | ||
* "uid" = "uid", | ||
* "label" = "name", | ||
* "uuid" = "uuid" | ||
* }, | ||
* revision_metadata_keys = { | ||
* "revision_created" = "revision_timestamp", | ||
* "revision_user" = "revision_user", | ||
* "revision_log_message" = "revision_log" | ||
* }, | ||
* links = { | ||
* "canonical" = "/tpr-service/{tpr_service}", | ||
* "edit-form" = "/admin/content/tpr-service/{tpr_service}/edit", | ||
* "delete-form" = "/admin/content/tpr-service/{tpr_service}/delete", | ||
* "collection" = "/admin/content/tpr-service" | ||
* }, | ||
* field_ui_base_route = "tpr_service.settings" | ||
* ) | ||
*/ | ||
class Service extends TprEntityBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getMigration(): ?string { | ||
return 'tpr_service'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | ||
$fields = parent::baseFieldDefinitions($entity_type); | ||
$fields['description'] = BaseFieldDefinition::create('text_with_summary') | ||
->setTranslatable(TRUE) | ||
->setLabel(new TranslatableMarkup('Description')) | ||
->setDisplayConfigurable('form', TRUE) | ||
->setDisplayConfigurable('view', TRUE); | ||
|
||
return $fields; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.