Skip to content

Commit

Permalink
VACMS-15422: Migration config and code updated for title and official…
Browse files Browse the repository at this point in the history
… name.
  • Loading branch information
omahane committed Oct 18, 2023
1 parent 3d26346 commit f0fc95b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ process:
method: row
value:
- OS
title:
field_official_name:
plugin: skip_on_empty
method: row
source: name
Expand Down Expand Up @@ -236,13 +236,13 @@ destination:
- field_geolocation
- field_phone_number
- field_office_hours
- field_official_name
- field_timezone
- new_revision
- revision_default
- revision_log
- revision_timestamp
- revision_uid
- title
- uid
migration_dependencies:
required: { }
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ process:
method: row
value:
- OS
title:
field_official_name:
plugin: skip_on_empty
method: row
source: name
Expand Down Expand Up @@ -251,13 +251,13 @@ destination:
- 'field_geolocation'
- field_phone_number
- field_office_hours
- field_official_name
- field_timezone
- new_revision
- revision_default
- revision_log
- revision_timestamp
- revision_uid
- title
- uid
# Dependency on other migrations.
migration_dependencies:
Expand Down
7 changes: 4 additions & 3 deletions docroot/modules/custom/va_gov_migrate/va_gov_migrate.module
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@ function _va_gov_migrate_process_va_form(EntityInterface &$entity) {
}

/**
* Set default Vet Center title.
* Set default Vet Center or Vet Center - Outstation title.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* Entity.
*/
function _va_gov_migrate_set_default_vet_center_title(EntityInterface &$entity) {
if ($entity->bundle() !== 'vet_center' || (!$entity instanceof NodeInterface)) {
$bundles = ['vet_center', 'vet_center_outstation'];
if (!in_array($entity->bundle(), $bundles) || (!$entity instanceof NodeInterface)) {
return;
}

/** @var \Drupal\node\NodeInterface $entity */
// If a Vet Center title is empty copy the value from field_official_name.
// If a title is empty, copy the value from field_official_name.
if (empty($entity->getTitle())) {
$default_title = $entity->get('field_official_name')->value ?: '- none -';
$entity->setTitle($default_title);
Expand Down

0 comments on commit f0fc95b

Please sign in to comment.