From dfd00a7f4e31b61c8d1f1d6d1f214d5e11ba7707 Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Mon, 3 Mar 2025 12:54:02 -0800 Subject: [PATCH 1/6] VACMS-20726: Adds script to migrate widget names for MHV to VA.gov transition. --- .../ReactWidgetUpdatesForMHVMigration.php | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php new file mode 100644 index 0000000000..c8c2503bc0 --- /dev/null +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -0,0 +1,142 @@ + 'modern-refill-track-prescriptions-page', + 'health-records' => 'modern-get-medical-records-page', + 'lab-and-test-results' => 'modern-get-medical-records-page', + 'messaging' => 'modern-secure-messaging-page', + 'schedule-appointments' => 'modern-schedule-view-va-appointments-page', + ]; + + /** + * The widget type field name. This is the main target for the migration. + * + * @var string + */ + const WIDGET_FIELD_NAME = 'field_widget_type'; + + /** + * The Drupal Path Alias manager service. + * + * @var \Drupal\path_alias\AliasManager + */ + protected AliasManager $pathAliasManager; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + $instance = parent::create($container); + $instance->pathAliasManager = $container->get('path_alias.manager'); + return $instance; + } + + /** + * {@inheritdoc} + */ + public function getTitle():string { + return "CTA Widget Updates for 'MHV on VA.gov' migration"; + } + + /** + * {@inheritdoc} + */ + public function getDescription():string { + return <<databaseConnection->select('paragraph__field_widget_type', 'wt'); + $select->fields('wt', ['entity_id']); + $select->condition('wt.field_widget_type_value', array_keys(self::WIDGET_MAP), 'IN'); + return $select->execute()->fetchCol(); + } + + /** + * {@inheritdoc} + * + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * Thrown if the entity type doesn't exist. + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * Thrown if the storage handler couldn't be loaded. */ + public function processOne(string $key, mixed $item, array &$sandbox): string { + /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ + $paragraph = $this->entityTypeManager->getStorage('paragraph')->load($item); + if (!$paragraph) { + return "There was a problem loading paragraph id {$item}. Further investigation is needed. Skipping."; + } + if (!$paragraph->hasField(self::WIDGET_FIELD_NAME)) { + return "The paragraph id {$item} doesn't have the necessary field. This is unexpected and further investigation is needed. Skipping."; + } + $parentEntity = $paragraph->getParentEntity(); + if (!$parentEntity) { + return "There is no parent node for paragraph id {$item}. This appears to be an orphaned paragraph. Skipping."; + } + // Make sure we are acting on a node. + if (!$parentEntity instanceof NodeInterface) { + $parentEntityType = $parentEntity->getEntityType()->getLabel(); + $parentEntityBundle = $parentEntity->bundle(); + return "The parent entity for paragraph id {$item} is not a node. This is unexpected and warrants manual migration for this paragraph. The parent bundle is {$parentEntityBundle} and the entity type is {$parentEntityType}."; + } + try { + $currentWidgetName = $paragraph->get(self::WIDGET_FIELD_NAME)->value; + $newWidgetName = self::WIDGET_MAP[$currentWidgetName]; + if (!isset(self::WIDGET_MAP[$currentWidgetName])) { + return "New widget name not found for paragraph id {$item} with widget name {$currentWidgetName}. Skipping."; + } + // Set the name of this widget to the new MHV widget name. + $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); + $paragraph->save(); + // Get the path alias for this node for logging. + $alias = $this->pathAliasManager->getAliasByPath('/node' . $parentEntity->id()); + return "Updated from {$currentWidgetName} to {$newWidgetName} id {$item} for node id {$parentEntity->id()} having path alias of {$alias}"; + } + catch (EntityStorageException $e) { + return "There was an error saving paragraph id {$item}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"; + } + } + +} From 279fe539ff17568caa89983f44d9a2a205d552d7 Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:35:17 -0800 Subject: [PATCH 2/6] VACMS-20726: Fixes typo preventing path alias from working as intended. --- .../src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php index c8c2503bc0..c4b1489151 100644 --- a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -131,7 +131,7 @@ public function processOne(string $key, mixed $item, array &$sandbox): string { $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); $paragraph->save(); // Get the path alias for this node for logging. - $alias = $this->pathAliasManager->getAliasByPath('/node' . $parentEntity->id()); + $alias = $this->pathAliasManager->getAliasByPath('/node/' . $parentEntity->id()); return "Updated from {$currentWidgetName} to {$newWidgetName} id {$item} for node id {$parentEntity->id()} having path alias of {$alias}"; } catch (EntityStorageException $e) { From e25ec564240dfb4f94990b37282dc539197355d0 Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Thu, 6 Mar 2025 12:01:26 -0800 Subject: [PATCH 3/6] VACMS-20726: Move to using a csv as canonical data source for migration. Process each node for react widget updates. --- .../data/NodesForMHVReactWidgetMigration.csv | 408 ++++++++++++++++++ .../ReactWidgetUpdatesForMHVMigration.php | 160 +++++-- 2 files changed, 521 insertions(+), 47 deletions(-) create mode 100644 docroot/modules/custom/va_gov_batch/data/NodesForMHVReactWidgetMigration.csv diff --git a/docroot/modules/custom/va_gov_batch/data/NodesForMHVReactWidgetMigration.csv b/docroot/modules/custom/va_gov_batch/data/NodesForMHVReactWidgetMigration.csv new file mode 100644 index 0000000000..fc811e0e3a --- /dev/null +++ b/docroot/modules/custom/va_gov_batch/data/NodesForMHVReactWidgetMigration.csv @@ -0,0 +1,408 @@ +Node ID,Node Type,Status,Path,Widget Type +27,page,1,/health-care/refill-track-prescriptions,rx +33,page,1,/health-care/get-medical-records,health-records +37,page,1,/health-care/schedule-view-va-appointments,schedule-appointments +38,page,1,/health-care/secure-messaging,messaging +40,page,1,/health-care/view-test-and-lab-results,lab-and-test-results +268,health_care_region_detail_page,1,/pittsburgh-health-care/pharmacy,rx +195,health_care_region_detail_page,1,/pittsburgh-health-care/make-an-appointment,schedule-appointments +2450,health_care_region_detail_page,1,/altoona-health-care/make-an-appointment,schedule-appointments +2609,health_care_region_detail_page,1,/coatesville-health-care/make-an-appointment,schedule-appointments +2554,health_care_region_detail_page,1,/butler-health-care/make-an-appointment,schedule-appointments +2467,health_care_region_detail_page,1,/altoona-health-care/pharmacy,rx +2615,health_care_region_detail_page,1,/coatesville-health-care/pharmacy,rx +2560,health_care_region_detail_page,1,/butler-health-care/pharmacy,rx +2763,health_care_region_detail_page,1,/erie-health-care/make-an-appointment,schedule-appointments +2439,health_care_region_detail_page,1,/lebanon-health-care/medical-records-office-replaced,health-records +2965,health_care_region_detail_page,1,/philadelphia-health-care/make-an-appointment,schedule-appointments +2440,health_care_region_detail_page,1,/lebanon-health-care/pharmacy,rx +2971,health_care_region_detail_page,1,/philadelphia-health-care/pharmacy,rx +2435,health_care_region_detail_page,1,/lebanon-health-care/make-an-appointment,schedule-appointments +2769,health_care_region_detail_page,1,/erie-health-care/pharmacy,rx +2669,health_care_region_detail_page,1,/wilkes-barre-health-care/make-an-appointment,schedule-appointments +2713,health_care_region_detail_page,1,/wilmington-health-care/make-an-appointment,schedule-appointments +2675,health_care_region_detail_page,1,/wilkes-barre-health-care/pharmacy,rx +2719,health_care_region_detail_page,1,/wilmington-health-care/pharmacy,rx +36,page,1,/health-care/order-hearing-aid-batteries-and-accessories,rx +7910,support_resources_detail_page,0,/resources/test-about-account-information-sample-text,health-records +6246,health_care_region_detail_page,1,/cheyenne-health-care/make-an-appointment,schedule-appointments +6252,health_care_region_detail_page,1,/western-colorado-health-care/make-an-appointment,schedule-appointments +6267,health_care_region_detail_page,1,/eastern-colorado-health-care/make-an-appointment,schedule-appointments +6302,health_care_region_detail_page,1,/montana-health-care/make-an-appointment,schedule-appointments +6360,health_care_region_detail_page,1,/oklahoma-city-health-care/make-an-appointment,schedule-appointments +6393,health_care_region_detail_page,1,/sheridan-health-care/make-an-appointment,schedule-appointments +6498,health_care_region_detail_page,1,/eastern-oklahoma-health-care/make-an-appointment,schedule-appointments +6963,health_care_region_detail_page,1,/fayetteville-coastal-health-care/make-an-appointment,schedule-appointments +6999,health_care_region_detail_page,1,/asheville-health-care/make-an-appointment,schedule-appointments +7004,health_care_region_detail_page,1,/durham-health-care/make-an-appointment,schedule-appointments +7070,health_care_region_detail_page,1,/richmond-health-care/make-an-appointment,schedule-appointments +7083,health_care_region_detail_page,1,/hampton-health-care/make-an-appointment,schedule-appointments +7123,health_care_region_detail_page,1,/salisbury-health-care/make-an-appointment,schedule-appointments +17747,health_care_region_detail_page,1,/charleston-health-care/make-an-appointment,schedule-appointments +7258,health_care_region_detail_page,1,/fayetteville-arkansas-health-care/make-an-appointment,schedule-appointments +7612,health_care_region_detail_page,1,/shreveport-health-care/make-an-appointment,schedule-appointments +7642,health_care_region_detail_page,1,/alexandria-health-care/make-an-appointment,schedule-appointments +7662,health_care_region_detail_page,1,/central-arkansas-health-care/make-an-appointment,schedule-appointments +7727,health_care_region_detail_page,1,/houston-health-care/make-an-appointment,schedule-appointments +7767,health_care_region_detail_page,1,/jackson-health-care/make-an-appointment,schedule-appointments +7790,health_care_region_detail_page,1,/gulf-coast-health-care/make-an-appointment,schedule-appointments +7865,health_care_region_detail_page,1,/southeast-louisiana-health-care/make-an-appointment,schedule-appointments +7877,health_care_region_detail_page,1,/northern-california-health-care/make-an-appointment,schedule-appointments +7925,health_care_region_detail_page,1,/san-francisco-health-care/make-an-appointment,schedule-appointments +7967,health_care_region_detail_page,1,/central-california-health-care/make-an-appointment,schedule-appointments +7987,health_care_region_detail_page,1,/pacific-islands-health-care/make-an-appointment,schedule-appointments +8032,health_care_region_detail_page,1,/palo-alto-health-care/make-an-appointment,schedule-appointments +8052,health_care_region_detail_page,1,/southern-nevada-health-care/make-an-appointment,schedule-appointments +8098,health_care_region_detail_page,1,/sierra-nevada-health-care/make-an-appointment,schedule-appointments +8144,health_care_region_detail_page,1,/minneapolis-health-care/make-an-appointment,schedule-appointments +8147,health_care_region_detail_page,1,/black-hills-health-care/make-an-appointment,schedule-appointments +8188,health_care_region_detail_page,1,/nebraska-western-iowa-health-care/make-an-appointment,schedule-appointments +8237,health_care_region_detail_page,1,/iowa-city-health-care/make-an-appointment,schedule-appointments +8261,health_care_region_detail_page,1,/central-iowa-health-care/make-an-appointment,schedule-appointments +19266,health_care_region_detail_page,1,/kansas-city-health-care/make-an-appointment,schedule-appointments +8387,health_care_region_detail_page,1,/sioux-falls-health-care/make-an-appointment,schedule-appointments +8441,health_care_region_detail_page,1,/st-cloud-health-care/make-an-appointment,schedule-appointments +8551,health_care_region_detail_page,1,/northport-health-care/make-an-appointment,schedule-appointments +8557,health_care_region_detail_page,1,/albany-health-care/make-an-appointment,schedule-appointments +8618,health_care_region_detail_page,1,/bronx-health-care/make-an-appointment,schedule-appointments +8657,health_care_region_detail_page,1,/finger-lakes-health-care/make-an-appointment,schedule-appointments +8703,health_care_region_detail_page,1,/syracuse-health-care/make-an-appointment,schedule-appointments +9298,health_care_region_detail_page,1,/western-new-york-health-care/make-an-appointment,schedule-appointments +9302,health_care_region_detail_page,1,/hudson-valley-health-care/make-an-appointment,schedule-appointments +9403,health_care_region_detail_page,1,/new-york-harbor-health-care/make-an-appointment,schedule-appointments +9527,health_care_region_detail_page,1,/new-jersey-health-care/make-an-appointment,schedule-appointments +6251,health_care_region_detail_page,1,/western-colorado-health-care/pharmacy,rx +6270,health_care_region_detail_page,1,/cheyenne-health-care/pharmacy,rx +6292,health_care_region_detail_page,1,/eastern-colorado-health-care/pharmacy,rx +6325,health_care_region_detail_page,1,/montana-health-care/pharmacy,rx +6366,health_care_region_detail_page,1,/oklahoma-city-health-care/pharmacy,rx +6453,health_care_region_detail_page,1,/sheridan-health-care/pharmacy,rx +16551,health_care_region_detail_page,1,/orlando-health-care/pharmacy,rx +6509,health_care_region_detail_page,1,/eastern-oklahoma-health-care/pharmacy,rx +6969,health_care_region_detail_page,1,/fayetteville-coastal-health-care/pharmacy,rx +7009,health_care_region_detail_page,1,/asheville-health-care/pharmacy,rx +7012,health_care_region_detail_page,1,/durham-health-care/pharmacy,rx +7075,health_care_region_detail_page,1,/richmond-health-care/pharmacy,rx +7094,health_care_region_detail_page,1,/hampton-health-care/pharmacy,rx +7132,health_care_region_detail_page,1,/salisbury-health-care/pharmacy,rx +17768,health_care_region_detail_page,1,/charleston-health-care/pharmacy,rx +7266,health_care_region_detail_page,1,/fayetteville-arkansas-health-care/pharmacy,rx +7619,health_care_region_detail_page,1,/shreveport-health-care/pharmacy,rx +7669,health_care_region_detail_page,1,/central-arkansas-health-care/pharmacy,rx +7700,health_care_region_detail_page,1,/alexandria-health-care/pharmacy,rx +7732,health_care_region_detail_page,1,/houston-health-care/pharmacy,rx +7773,health_care_region_detail_page,1,/jackson-health-care/pharmacy,rx +7796,health_care_region_detail_page,1,/gulf-coast-health-care/pharmacy,rx +7883,health_care_region_detail_page,1,/northern-california-health-care/pharmacy,rx +7895,health_care_region_detail_page,1,/southeast-louisiana-health-care/pharmacy,rx +7930,health_care_region_detail_page,1,/san-francisco-health-care/pharmacy,rx +7972,health_care_region_detail_page,1,/central-california-health-care/pharmacy,rx +7993,health_care_region_detail_page,1,/pacific-islands-health-care/pharmacy,rx +8037,health_care_region_detail_page,1,/palo-alto-health-care/pharmacy,rx +8056,health_care_region_detail_page,1,/southern-nevada-health-care/pharmacy,rx +8104,health_care_region_detail_page,1,/sierra-nevada-health-care/pharmacy,rx +8154,health_care_region_detail_page,1,/black-hills-health-care/pharmacy,rx +8186,health_care_region_detail_page,1,/minneapolis-health-care/pharmacy,rx +8247,health_care_region_detail_page,1,/iowa-city-health-care/pharmacy,rx +8265,health_care_region_detail_page,1,/central-iowa-health-care/pharmacy,rx +8301,health_care_region_detail_page,1,/nebraska-western-iowa-health-care/pharmacy,rx +19271,health_care_region_detail_page,1,/kansas-city-health-care/pharmacy,rx +8389,health_care_region_detail_page,1,/sioux-falls-health-care/pharmacy,rx +8446,health_care_region_detail_page,1,/st-cloud-health-care/pharmacy,rx +8556,health_care_region_detail_page,1,/northport-health-care/pharmacy,rx +8570,health_care_region_detail_page,1,/albany-health-care/pharmacy,rx +8623,health_care_region_detail_page,1,/bronx-health-care/pharmacy,rx +8662,health_care_region_detail_page,1,/finger-lakes-health-care/pharmacy,rx +8708,health_care_region_detail_page,1,/syracuse-health-care/pharmacy,rx +9307,health_care_region_detail_page,1,/hudson-valley-health-care/pharmacy,rx +9321,health_care_region_detail_page,1,/western-new-york-health-care/pharmacy,rx +9408,health_care_region_detail_page,1,/new-york-harbor-health-care/pharmacy,rx +9533,health_care_region_detail_page,1,/new-jersey-health-care/pharmacy,rx +23411,health_care_region_detail_page,1,/puget-sound-health-care/make-an-appointment,schedule-appointments +23192,health_care_region_detail_page,1,/louisville-health-care/pharmacy,rx +16545,health_care_region_detail_page,1,/orlando-health-care/make-an-appointment,schedule-appointments +16551,health_care_region_detail_page,1,/orlando-health-care/pharmacy,rx +16630,health_care_region_detail_page,1,/caribbean-health-care/make-an-appointment,schedule-appointments +16635,health_care_region_detail_page,1,/caribbean-health-care/pharmacy,rx +16709,health_care_region_detail_page,1,/miami-health-care/make-an-appointment,schedule-appointments +16714,health_care_region_detail_page,1,/miami-health-care/pharmacy,rx +16784,health_care_region_detail_page,1,/north-florida-health-care/pharmacy,rx +16788,health_care_region_detail_page,1,/north-florida-health-care/make-an-appointment,schedule-appointments +16989,health_care_region_detail_page,1,/west-palm-beach-health-care/make-an-appointment,schedule-appointments +16994,health_care_region_detail_page,1,/west-palm-beach-health-care/pharmacy,rx +17005,health_care_region_detail_page,1,/tampa-health-care/make-an-appointment,schedule-appointments +17047,health_care_region_detail_page,1,/tampa-health-care/pharmacy,rx +17204,health_care_region_detail_page,1,/birmingham-health-care/make-an-appointment,schedule-appointments +17209,health_care_region_detail_page,1,/birmingham-health-care/pharmacy,rx +17261,health_care_region_detail_page,1,/columbia-south-carolina-health-care/make-an-appointment,schedule-appointments +17266,health_care_region_detail_page,1,/columbia-south-carolina-health-care/pharmacy,rx +17411,health_care_region_detail_page,1,/augusta-health-care/make-an-appointment,schedule-appointments +17416,health_care_region_detail_page,1,/augusta-health-care/pharmacy,rx +17548,health_care_region_detail_page,1,/central-alabama-health-care/make-an-appointment,schedule-appointments +17552,health_care_region_detail_page,1,/central-alabama-health-care/pharmacy,rx +23542,health_care_region_detail_page,1,/walla-walla-health-care/make-an-appointment,schedule-appointmentsCurrent sign-in widget links to MHV on VA.gov +23551,health_care_region_detail_page,1,/walla-walla-health-care/pharmacy,rx"No widget but link to My VA Health sign-in, recommend don't change" +26959,health_care_region_detail_page,1,/southern-oregon-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26964,health_care_region_detail_page,1,/southern-oregon-health-care/pharmacy,rx"No widget, has a link to MHV Classic to register/sign up, outdated and should be changed " +17828,health_care_region_detail_page,1,/dublin-health-care/make-an-appointment,schedule-appointments +17832,health_care_region_detail_page,1,/dublin-health-care/pharmacy,rx +17862,health_care_region_detail_page,1,/tuscaloosa-health-care/make-an-appointment,schedule-appointments +17867,health_care_region_detail_page,1,/tuscaloosa-health-care/pharmacy,rx +18264,health_care_region_detail_page,1,/amarillo-health-care/make-an-appointment,schedule-appointments +18269,health_care_region_detail_page,1,/amarillo-health-care/pharmacy,rx +18373,health_care_region_detail_page,1,/central-texas-health-care/make-an-appointment,schedule-appointments +27443,health_care_region_detail_page,1,/boston-health-care/pharmacy,rx +18497,health_care_region_detail_page,1,/north-texas-health-care/make-an-appointment,schedule-appointments +18502,health_care_region_detail_page,1,/north-texas-health-care/pharmacy,rx +18668,health_care_region_detail_page,1,/texas-valley-health-care/make-an-appointment,schedule-appointments +18673,health_care_region_detail_page,1,/texas-valley-health-care/pharmacy,rx +18744,health_care_region_detail_page,1,/south-texas-health-care/make-an-appointment,schedule-appointments +18754,health_care_region_detail_page,1,/south-texas-health-care/pharmacy,rx +18780,health_care_region_detail_page,1,/el-paso-health-care/make-an-appointment,schedule-appointments +18785,health_care_region_detail_page,1,/el-paso-health-care/pharmacy,rx +18875,health_care_region_detail_page,1,/west-texas-health-care/make-an-appointment,schedule-appointments +18880,health_care_region_detail_page,1,/west-texas-health-care/pharmacy,rx +19093,health_care_region_detail_page,1,/columbia-missouri-health-care/make-an-appointment,schedule-appointments +19131,health_care_region_detail_page,1,/columbia-missouri-health-care/pharmacy,rx +19266,health_care_region_detail_page,1,/kansas-city-health-care/make-an-appointment,schedule-appointments +19377,health_care_region_detail_page,1,/poplar-bluff-health-care/pharmacy,rx +19522,health_care_region_detail_page,1,/st-louis-health-care/make-an-appointment,schedule-appointments +19529,health_care_region_detail_page,1,/st-louis-health-care/pharmacy,rx +19675,health_care_region_detail_page,1,/wichita-health-care/make-an-appointment,schedule-appointments +19680,health_care_region_detail_page,1,/wichita-health-care/pharmacy,rx +19522,health_care_region_detail_page,1,/st-louis-health-care/make-an-appointment,schedule-appointments +19529,health_care_region_detail_page,1,/st-louis-health-care/pharmacy,rx +19821,health_care_region_detail_page,1,/eastern-kansas-health-care/make-an-appointment,schedule-appointments +19680,health_care_region_detail_page,1,/wichita-health-care/pharmacy,rx +19821,health_care_region_detail_page,1,/eastern-kansas-health-care/make-an-appointment,schedule-appointments +19826,health_care_region_detail_page,1,/eastern-kansas-health-care/pharmacy,rx +20144,health_care_region_detail_page,1,/dayton-health-care/make-an-appointment,schedule-appointments +20005,health_care_region_detail_page,1,/chillicothe-health-care/pharmacy,rx +20027,health_care_region_detail_page,1,/indiana-health-care/make-an-appointment,schedule-appointments +20050,health_care_region_detail_page,1,/indiana-health-care/pharmacy,rx +20144,health_care_region_detail_page,1,/dayton-health-care/make-an-appointment,schedule-appointments +20153,health_care_region_detail_page,1,/dayton-health-care/pharmacy,rx +20198,health_care_region_detail_page,1,/ann-arbor-health-care/make-an-appointment,schedule-appointments +20203,health_care_region_detail_page,1,/ann-arbor-health-care/medical-records-office-replaced,health-records +20204,health_care_region_detail_page,1,/ann-arbor-health-care/pharmacy,rx +20374,health_care_region_detail_page,1,/detroit-health-care/make-an-appointment,schedule-appointments +20379,health_care_region_detail_page,1,/detroit-health-care/pharmacy,rx +33457,health_care_region_detail_page,1,/greater-los-angeles-health-care/make-an-appointment,schedule-appointments +20443,health_care_region_detail_page,1,/battle-creek-health-care/pharmacy,rx +20507,health_care_region_detail_page,1,/northeast-ohio-health-care/make-an-appointment,schedule-appointments +20512,health_care_region_detail_page,1,/northeast-ohio-health-care/pharmacy,rx +23046,health_care_region_detail_page,1,/central-ohio-health-care/make-an-appointment,schedule-appointmentsCurrent sign-in widget links to MHV on VA.gov +23050,health_care_region_detail_page,1,/central-ohio-health-care/medical-records-office,health-records"Looks to be the old widget, linking to MHV Classic? " +23051,health_care_region_detail_page,1,/central-ohio-health-care/pharmacy,rx"No widget, link to old MHV" +20633,health_care_region_detail_page,1,/northern-indiana-health-care/make-an-appointment,schedule-appointments +20634,health_care_region_detail_page,1,/northern-indiana-health-care/pharmacy,rx +20747,health_care_region_detail_page,1,/cincinnati-health-care/make-an-appointment,schedule-appointments +20761,health_care_region_detail_page,1,/cincinnati-health-care/pharmacy,rx +23046,health_care_region_detail_page,1,/central-ohio-health-care/make-an-appointment,schedule-appointmentsCurrent sign-in widget links to MHV on VA.gov +23050,health_care_region_detail_page,1,/central-ohio-health-care/medical-records-office,health-records"Looks to be the old widget, linking to MHV Classic" +23051,health_care_region_detail_page,1,/central-ohio-health-care/pharmacy,rx"No widget, link to old MHV" +23135,health_care_region_detail_page,1,/lexington-health-care/make-an-appointment,schedule-appointments +23140,health_care_region_detail_page,1,/lexington-health-care/pharmacy,rx +23190,health_care_region_detail_page,1,/louisville-health-care/make-an-appointment,schedule-appointments +23416,health_care_region_detail_page,1,/puget-sound-health-care/pharmacy,rx"Looks to be the old widget, linking to MHV Classic" +26871,health_care_region_detail_page,1,/roseburg-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26873,health_care_region_detail_page,1,/roseburg-health-care/pharmacy,rx"Looks to be the old widget, linking to MHV Classic" +27427,health_care_region_detail_page,1,/white-river-junction-health-care/make-an-appointment,schedule-appointments +23416,health_care_region_detail_page,1,/puget-sound-health-care/pharmacy,rx +23459,health_care_region_detail_page,1,/mountain-home-health-care/make-an-appointment,schedule-appointments +23464,health_care_region_detail_page,1,/mountain-home-health-care/pharmacy,rx +23542,health_care_region_detail_page,1,/walla-walla-health-care/make-an-appointment,schedule-appointmentsCurrent sign-in widget links to MHV on VA.gov +23551,health_care_region_detail_page,1,/walla-walla-health-care/pharmacy,rx"No widget but link to My VA Health sign-in, recommend don't change" +23565,health_care_region_detail_page,1,/boise-health-care/make-an-appointment,schedule-appointments +23567,health_care_region_detail_page,1,/boise-health-care/pharmacy,rx +26871,health_care_region_detail_page,1,/roseburg-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26873,health_care_region_detail_page,1,/roseburg-health-care/pharmacy,rx"Looks to be the old widget, linking to MHV Classic" +26941,health_care_region_detail_page,1,/spokane-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26943,health_care_region_detail_page,1,/spokane-health-care/pharmacy,rx"No widget but link to My VA Health sign-in, recommend don't change" +27094,health_care_region_detail_page,1,/memphis-health-care/make-an-appointment,schedule-appointments +26964,health_care_region_detail_page,1,/southern-oregon-health-care/pharmacy,rx"No widget, link to old MHV" +27066,health_care_region_detail_page,1,/portland-health-care/make-an-appointment,schedule-appointments +27068,health_care_region_detail_page,1,/portland-health-care/pharmacy,rx +27270,health_care_region_detail_page,1,/bedford-health-care/make-an-appointment,schedule-appointments +27275,health_care_region_detail_page,1,/bedford-health-care/pharmacy,rx +27159,health_care_region_detail_page,1,/tennessee-valley-health-care/make-an-appointment,schedule-appointments +27161,health_care_region_detail_page,1,/tennessee-valley-health-care/pharmacy,rx +27270,health_care_region_detail_page,1,/bedford-health-care/make-an-appointment,schedule-appointments +27275,health_care_region_detail_page,1,/bedford-health-care/pharmacy,rx +27421,health_care_region_detail_page,1,/boston-health-care/make-an-appointment,schedule-appointments +27427,health_care_region_detail_page,1,/white-river-junction-health-care/make-an-appointment,schedule-appointments +27429,health_care_region_detail_page,1,/white-river-junction-health-care/pharmacy,rx +27443,health_care_region_detail_page,1,/boston-health-care/pharmacy,rx +6403,health_care_region_detail_page,1,/salt-lake-city-health-care/make-an-appointment,schedule-appointments +6466,health_care_region_detail_page,1,/salt-lake-city-health-care/pharmacy,rx +7146,health_care_region_detail_page,1,/salem-health-care/make-an-appointment,schedule-appointments +7152,health_care_region_detail_page,1,/salem-health-care/pharmacy,rx +8098,health_care_region_detail_page,1,/sierra-nevada-health-care/make-an-appointment,schedule-appointments +8104,health_care_region_detail_page,1,/sierra-nevada-health-care/pharmacy,rx +8154,health_care_region_detail_page,1,/black-hills-health-care/pharmacy,rx +8237,health_care_region_detail_page,1,/iowa-city-health-care/make-an-appointment,schedule-appointments +8247,health_care_region_detail_page,1,/iowa-city-health-care/pharmacy,rx +8340,health_care_region_detail_page,1,/fargo-health-care/make-an-appointment,schedule-appointments +8344,health_care_region_detail_page,1,/fargo-health-care/pharmacy,rx +8551,health_care_region_detail_page,1,/northport-health-care/make-an-appointment,schedule-appointments +8556,health_care_region_detail_page,1,/northport-health-care/pharmacy,rx +9298,health_care_region_detail_page,1,/western-new-york-health-care/make-an-appointment,schedule-appointments +9302,health_care_region_detail_page,1,/hudson-valley-health-care/make-an-appointment,schedule-appointments +9307,health_care_region_detail_page,1,/hudson-valley-health-care/pharmacy,rx +9321,health_care_region_detail_page,1,/western-new-york-health-care/pharmacy,rx +16515,health_care_region_detail_page,1,/bay-pines-health-care/make-an-appointment,schedule-appointments +16532,health_care_region_detail_page,1,/bay-pines-health-care/pharmacy,rx +16551,health_care_region_detail_page,1,/orlando-health-care/pharmacy,rx +16635,health_care_region_detail_page,1,/caribbean-health-care/pharmacy,rx +17204,health_care_region_detail_page,1,/birmingham-health-care/make-an-appointment,schedule-appointments +17209,health_care_region_detail_page,1,/birmingham-health-care/pharmacy,rx +17643,health_care_region_detail_page,1,/atlanta-health-care/make-an-appointment,schedule-appointments +17647,health_care_region_detail_page,1,/atlanta-health-care/pharmacy,rx +17747,health_care_region_detail_page,1,/charleston-health-care/make-an-appointment,schedule-appointments +17768,health_care_region_detail_page,1,/charleston-health-care/pharmacy,rx +18269,health_care_region_detail_page,1,/amarillo-health-care/pharmacy,rx +18373,health_care_region_detail_page,1,/central-texas-health-care/make-an-appointment,schedule-appointments +18378,health_care_region_detail_page,1,/central-texas-health-care/pharmacy,rx +18673,health_care_region_detail_page,1,/texas-valley-health-care/pharmacy,rx +19266,health_care_region_detail_page,1,/kansas-city-health-care/make-an-appointment,schedule-appointments +19271,health_care_region_detail_page,1,/kansas-city-health-care/pharmacy,rx +19285,health_care_region_detail_page,1,/marion-health-care/make-an-appointment,schedule-appointments +19292,health_care_region_detail_page,1,/marion-health-care/pharmacy,rx +19372,health_care_region_detail_page,1,/poplar-bluff-health-care/make-an-appointment,schedule-appointments +19377,health_care_region_detail_page,1,/poplar-bluff-health-care/pharmacy,rx +19675,health_care_region_detail_page,1,/wichita-health-care/make-an-appointment,schedule-appointments +19680,health_care_region_detail_page,1,/wichita-health-care/pharmacy,rx +20001,health_care_region_detail_page,1,/chillicothe-health-care/make-an-appointment,schedule-appointments +20005,health_care_region_detail_page,1,/chillicothe-health-care/pharmacy,rx +20027,health_care_region_detail_page,1,/indiana-health-care/make-an-appointment,schedule-appointments +20050,health_care_region_detail_page,1,/indiana-health-care/pharmacy,rx +20144,health_care_region_detail_page,1,/dayton-health-care/make-an-appointment,schedule-appointments +20153,health_care_region_detail_page,1,/dayton-health-care/pharmacy,rx +20198,health_care_region_detail_page,1,/ann-arbor-health-care/make-an-appointment,schedule-appointments +20203,health_care_region_detail_page,1,/ann-arbor-health-care/medical-records-office-replaced,health-records +20204,health_care_region_detail_page,1,/ann-arbor-health-care/pharmacy,rx +20507,health_care_region_detail_page,1,/northeast-ohio-health-care/make-an-appointment,schedule-appointments +20512,health_care_region_detail_page,1,/northeast-ohio-health-care/pharmacy,rx +20522,health_care_region_detail_page,1,/saginaw-health-care/make-an-appointment,schedule-appointments +20524,health_care_region_detail_page,1,/saginaw-health-care/pharmacy,rx +20747,health_care_region_detail_page,1,/cincinnati-health-care/make-an-appointment,schedule-appointments +20761,health_care_region_detail_page,1,/cincinnati-health-care/pharmacy,rx +23192,health_care_region_detail_page,1,/louisville-health-care/pharmacy,rx +23353,health_care_region_detail_page,1,/alaska-health-care/make-an-appointment,schedule-appointments +23358,health_care_region_detail_page,1,/alaska-health-care/pharmacy,rx +23411,health_care_region_detail_page,1,/puget-sound-health-care/make-an-appointment,schedule-appointments +26871,health_care_region_detail_page,1,/roseburg-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26873,health_care_region_detail_page,1,/roseburg-health-care/pharmacy,rx"Looks to be the old widget, linking to MHV Classic" +26941,health_care_region_detail_page,1,/spokane-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26943,health_care_region_detail_page,1,/spokane-health-care/pharmacy,rx"No widget but link to My VA Health sign-in, recommend don't change" +26959,health_care_region_detail_page,1,/southern-oregon-health-care/make-an-appointment,schedule-appointmentsDon't see anything on this page for sign-in +26964,health_care_region_detail_page,1,/southern-oregon-health-care/pharmacy,rx"No widget, link to old MHV" +27066,health_care_region_detail_page,1,/portland-health-care/make-an-appointment,schedule-appointments +27068,health_care_region_detail_page,1,/portland-health-care/pharmacy,rx +27094,health_care_region_detail_page,1,/memphis-health-care/make-an-appointment,schedule-appointments +27099,health_care_region_detail_page,1,/memphis-health-care/pharmacy,rx +27585,health_care_region_detail_page,1,/central-western-massachusetts-health-care/make-an-appointment,schedule-appointments +27591,health_care_region_detail_page,1,/central-western-massachusetts-health-care/pharmacy,rx +27613,health_care_region_detail_page,1,/providence-health-care/make-an-appointment,schedule-appointments +27615,health_care_region_detail_page,1,/providence-health-care/pharmacy,rx +27838,health_care_region_detail_page,1,/maine-health-care/make-an-appointment,schedule-appointments +27843,health_care_region_detail_page,1,/maine-health-care/pharmacy,rx +27879,health_care_region_detail_page,1,/manchester-health-care/make-an-appointment,schedule-appointments +27881,health_care_region_detail_page,1,/manchester-health-care/pharmacy,rx +27927,health_care_region_detail_page,1,/connecticut-health-care/make-an-appointment,schedule-appointments +27941,health_care_region_detail_page,1,/connecticut-health-care/pharmacy,rx +28368,health_care_region_detail_page,1,/new-mexico-health-care/make-an-appointment,schedule-appointments +28392,health_care_region_detail_page,1,/new-mexico-health-care/pharmacy,rx +28398,health_care_region_detail_page,1,/loma-linda-health-care/make-an-appointment,schedule-appointments +32890,health_care_region_detail_page,1,/loma-linda-health-care/pharmacy,rx +33099,health_care_region_detail_page,1,/san-diego-health-care/make-an-appointment,schedule-appointments +33101,health_care_region_detail_page,1,/san-diego-health-care/pharmacy,rx +33129,health_care_region_detail_page,1,/northern-arizona-health-care/make-an-appointment,schedule-appointments +33133,health_care_region_detail_page,0,/northern-arizona-health-care/medical-records-office-replaced,health-records +33134,health_care_region_detail_page,1,/northern-arizona-health-care/pharmacy,rx +33201,health_care_region_detail_page,1,/phoenix-health-care/make-an-appointment,schedule-appointments +33203,health_care_region_detail_page,1,/phoenix-health-care/pharmacy,rx +33226,health_care_region_detail_page,1,/southern-arizona-health-care/make-an-appointment,schedule-appointments +33231,health_care_region_detail_page,1,/southern-arizona-health-care/pharmacy,rx +33443,health_care_region_detail_page,1,/long-beach-health-care/make-an-appointment,schedule-appointments +33445,health_care_region_detail_page,1,/long-beach-health-care/pharmacy,rx +33457,health_care_region_detail_page,1,/greater-los-angeles-health-care/make-an-appointment,schedule-appointments +33462,health_care_region_detail_page,1,/greater-los-angeles-health-care/pharmacy,rx +33655,health_care_region_detail_page,1,/beckley-health-care/make-an-appointment,schedule-appointments +33657,health_care_region_detail_page,1,/beckley-health-care/pharmacy,rx +33758,health_care_region_detail_page,1,/martinsburg-health-care/make-an-appointment,schedule-appointments +33764,health_care_region_detail_page,1,/martinsburg-health-care/pharmacy,rx +33915,health_care_region_detail_page,1,/huntington-health-care/make-an-appointment,schedule-appointments +33916,health_care_region_detail_page,1,/huntington-health-care/medical-records-office,health-records +33917,health_care_region_detail_page,1,/huntington-health-care/pharmacy,rx +34081,health_care_region_detail_page,1,/clarksburg-health-care/make-an-appointment,schedule-appointments +34105,health_care_region_detail_page,1,/clarksburg-health-care/pharmacy,rx +34361,health_care_region_detail_page,1,/maryland-health-care/make-an-appointment,schedule-appointments +34363,health_care_region_detail_page,1,/maryland-health-care/pharmacy,rx +34402,health_care_region_detail_page,1,/washington-dc-health-care/make-an-appointment,schedule-appointments +34444,health_care_region_detail_page,1,/washington-dc-health-care/pharmacy,rx +34652,health_care_region_detail_page,1,/chicago-health-care/make-an-appointment,schedule-appointments +34654,health_care_region_detail_page,1,/chicago-health-care/pharmacy,rx +34718,health_care_region_detail_page,1,/hines-health-care/make-an-appointment,schedule-appointments +34728,health_care_region_detail_page,1,/hines-health-care/pharmacy,rx +34847,health_care_region_detail_page,1,/illiana-health-care/make-an-appointment,schedule-appointments +34854,health_care_region_detail_page,1,/illiana-health-care/pharmacy,rx +34962,health_care_region_detail_page,1,/iron-mountain-health-care/make-an-appointment,schedule-appointments +34972,health_care_region_detail_page,1,/iron-mountain-health-care/pharmacy,rx +35054,health_care_region_detail_page,1,/madison-health-care/make-an-appointment,schedule-appointments +35059,health_care_region_detail_page,1,/madison-health-care/pharmacy,rx +33340,centralized_content,1,/centralized-content/vamc-system-medical-records-page-content,health-records +35179,health_care_region_detail_page,1,/milwaukee-health-care/make-an-appointment,schedule-appointments +35185,health_care_region_detail_page,1,/milwaukee-health-care/pharmacy,rx +36286,health_care_region_detail_page,1,/lovell-federal-health-care-va/make-an-appointment,schedule-appointments"Current sign-in widget links to MHV on VA.gov; banner at the top is a link to MyVA Health signin, should keep" +36290,health_care_region_detail_page,1,/lovell-federal-health-care-tricare/medical-records-office,health-records"This is a tricare link and links to Gensis portal, recommend no changes" +36291,health_care_region_detail_page,1,/lovell-federal-health-care-va/pharmacy,rx"Link to MyVA health signin; banner at the top is a link to MyVA Health signin, should keep page as is" +36286,health_care_region_detail_page,1,/lovell-federal-health-care-va/make-an-appointment,schedule-appointments"Widget linking to VA.gov; banner at the top is a link to MyVA Health signin, should at minimum keep banner as is" +36290,health_care_region_detail_page,1,/lovell-federal-health-care-tricare/medical-records-office,health-records"This is a tricare link and links to Gensis portal, recommend no changes" +36291,health_care_region_detail_page,1,/lovell-federal-health-care-va/pharmacy,rx"Link to MyVA health signin; banner at the top is a link to MyVA Health signin, should keep page as is" +20198,health_care_region_detail_page,1,/ann-arbor-health-care/make-an-appointment,schedule-appointments +20203,health_care_region_detail_page,1,/ann-arbor-health-care/medical-records-office-replaced,health-records +20204,health_care_region_detail_page,1,/ann-arbor-health-care/pharmacy,rx +20438,health_care_region_detail_page,1,/battle-creek-health-care/make-an-appointment,schedule-appointments +20443,health_care_region_detail_page,1,/battle-creek-health-care/pharmacy,rx +27421,health_care_region_detail_page,1,/boston-health-care/make-an-appointment,schedule-appointments +27427,health_care_region_detail_page,1,/white-river-junction-health-care/make-an-appointment,schedule-appointments +27429,health_care_region_detail_page,1,/white-river-junction-health-care/pharmacy,rx +27443,health_care_region_detail_page,1,/boston-health-care/pharmacy,rx +27585,health_care_region_detail_page,1,/central-western-massachusetts-health-care/make-an-appointment,schedule-appointments +27591,health_care_region_detail_page,1,/central-western-massachusetts-health-care/pharmacy,rx +27613,health_care_region_detail_page,1,/providence-health-care/make-an-appointment,schedule-appointments +27615,health_care_region_detail_page,1,/providence-health-care/pharmacy,rx +27838,health_care_region_detail_page,1,/maine-health-care/make-an-appointment,schedule-appointments +27843,health_care_region_detail_page,1,/maine-health-care/pharmacy,rx +28368,health_care_region_detail_page,1,/new-mexico-health-care/make-an-appointment,schedule-appointments +28392,health_care_region_detail_page,1,/new-mexico-health-care/pharmacy,rx +28398,health_care_region_detail_page,1,/loma-linda-health-care/make-an-appointment,schedule-appointments +33099,health_care_region_detail_page,1,/san-diego-health-care/make-an-appointment,schedule-appointments +33101,health_care_region_detail_page,1,/san-diego-health-care/pharmacy,rx +33129,health_care_region_detail_page,1,/northern-arizona-health-care/make-an-appointment,schedule-appointments +33133,health_care_region_detail_page,0,/northern-arizona-health-care/medical-records-office-replaced,health-records +33134,health_care_region_detail_page,1,/northern-arizona-health-care/pharmacy,rx +33443,health_care_region_detail_page,1,/long-beach-health-care/make-an-appointment,schedule-appointments +33445,health_care_region_detail_page,1,/long-beach-health-care/pharmacy,rx +33457,health_care_region_detail_page,1,/greater-los-angeles-health-care/make-an-appointment,schedule-appointments +33462,health_care_region_detail_page,1,/greater-los-angeles-health-care/pharmacy,rx +33758,health_care_region_detail_page,1,/martinsburg-health-care/make-an-appointment,schedule-appointments +33764,health_care_region_detail_page,1,/martinsburg-health-care/pharmacy,rx +34081,health_care_region_detail_page,1,/clarksburg-health-care/make-an-appointment,schedule-appointments +34105,health_care_region_detail_page,1,/clarksburg-health-care/pharmacy,rx +34361,health_care_region_detail_page,1,/maryland-health-care/make-an-appointment,schedule-appointments +34363,health_care_region_detail_page,1,/maryland-health-care/pharmacy,rx +34402,health_care_region_detail_page,1,/washington-dc-health-care/make-an-appointment,schedule-appointments +34444,health_care_region_detail_page,1,/washington-dc-health-care/pharmacy,rx +34652,health_care_region_detail_page,1,/chicago-health-care/make-an-appointment,schedule-appointments +34654,health_care_region_detail_page,1,/chicago-health-care/pharmacy,rx +34718,health_care_region_detail_page,1,/hines-health-care/make-an-appointment,schedule-appointments +34972,health_care_region_detail_page,1,/iron-mountain-health-care/pharmacy,rx +35059,health_care_region_detail_page,1,/madison-health-care/pharmacy,rx +35270,health_care_region_detail_page,1,/tomah-health-care/make-an-appointment,schedule-appointments +35275,health_care_region_detail_page,1,/tomah-health-care/pharmacy,rx +19680,health_care_region_detail_page,1,/wichita-health-care/pharmacy,rx +17878,health_care_region_detail_page,1,/tuscaloosa-health-care/health-services/women-veteran-care,schedule-appointments +56902,page,1,/supporting-forms-for-claims,health-records +20027,health_care_region_detail_page,1,/indiana-health-care/make-an-appointment,schedule-appointments diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php index c4b1489151..28cf48fcfd 100644 --- a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -6,8 +6,8 @@ use Drupal\codit_batch_operations\BatchScriptInterface; use Drupal\Core\Entity\EntityStorageException; use Drupal\node\NodeInterface; -use Drupal\path_alias\AliasManager; -use Symfony\Component\DependencyInjection\ContainerInterface; +use League\Csv\Reader; +use League\Csv\Statement; /** * For VACMS-20726. @@ -37,20 +37,20 @@ class ReactWidgetUpdatesForMHVMigration extends BatchOperations implements Batch const WIDGET_FIELD_NAME = 'field_widget_type'; /** - * The Drupal Path Alias manager service. + * The path to the source of truth for the data migration. * - * @var \Drupal\path_alias\AliasManager + * @var string */ - protected AliasManager $pathAliasManager; + const DATA_FILE_LOCATION = __DIR__ . '/../../data/NodesForMHVReactWidgetMigration.csv'; /** - * {@inheritdoc} + * Enable for debugging. Prevents updating paragraphs. + * + * @todo Remove before pushing. + * + * @var bool */ - public static function create(ContainerInterface $container) { - $instance = parent::create($container); - $instance->pathAliasManager = $container->get('path_alias.manager'); - return $instance; - } + const DEBUG = TRUE; /** * {@inheritdoc} @@ -81,18 +81,25 @@ public function getCompletedMessage(): string { * {@inheritdoc} */ public function getItemType(): string { - return 'paragraph'; + return 'node'; } /** * {@inheritdoc} + * + * @throws \League\Csv\UnavailableStream + * @throws \League\Csv\Exception */ public function gatherItemsToProcess(): array { - // Finds CTA widget paragraphs for MHV. Returns ~413 records. - $select = $this->databaseConnection->select('paragraph__field_widget_type', 'wt'); - $select->fields('wt', ['entity_id']); - $select->condition('wt.field_widget_type_value', array_keys(self::WIDGET_MAP), 'IN'); - return $select->execute()->fetchCol(); + // Items to process represent Node IDs which we gather from the source csv. + $csvReader = Reader::createFromPath(self::DATA_FILE_LOCATION); + $csvReader->setHeaderOffset(0); + $records = (new Statement())->process($csvReader); + $nids = []; + foreach ($records->fetchColumnByOffset(0) as $value) { + $nids[$value] = $value; + } + return $nids; } /** @@ -101,42 +108,101 @@ public function gatherItemsToProcess(): array { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * Thrown if the entity type doesn't exist. * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * Thrown if the storage handler couldn't be loaded. */ + * Thrown if the storage handler couldn't be loaded. + * @throws \Drupal\Core\Entity\EntityMalformedException + * Thrown if the toUrl() could not find an entity id. + */ public function processOne(string $key, mixed $item, array &$sandbox): string { - /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ - $paragraph = $this->entityTypeManager->getStorage('paragraph')->load($item); - if (!$paragraph) { - return "There was a problem loading paragraph id {$item}. Further investigation is needed. Skipping."; - } - if (!$paragraph->hasField(self::WIDGET_FIELD_NAME)) { - return "The paragraph id {$item} doesn't have the necessary field. This is unexpected and further investigation is needed. Skipping."; - } - $parentEntity = $paragraph->getParentEntity(); - if (!$parentEntity) { - return "There is no parent node for paragraph id {$item}. This appears to be an orphaned paragraph. Skipping."; + /** @var \Drupal\node\NodeStorageInterface $nodeStorage */ + $nodeStorage = $this->entityTypeManager->getStorage('node'); + /** @var \Drupal\node\NodeInterface|null $node */ + $node = $nodeStorage->load($item); + if (!$node) { + return "There was a problem loading node id {$item}. Further investigation is needed. Skipping."; } - // Make sure we are acting on a node. - if (!$parentEntity instanceof NodeInterface) { - $parentEntityType = $parentEntity->getEntityType()->getLabel(); - $parentEntityBundle = $parentEntity->bundle(); - return "The parent entity for paragraph id {$item} is not a node. This is unexpected and warrants manual migration for this paragraph. The parent bundle is {$parentEntityBundle} and the entity type is {$parentEntityType}."; + + $path = $node->toUrl()->toString(); + $nodeMessage = "Node {$node->id()} at {$path}"; + + // Note unpublished nodes. We may leave these alone. TBD. Skipping for now. + if (!$node->isPublished()) { + $state = $node->get('moderation_state')->value; + $widgetStatus = 'has ' . ($this->hasWidget($node) ? 'a React widget' : 'no React widget'); + return $nodeMessage . " is not published. It's current status is {$state} and it {$widgetStatus}. Skipping"; } - try { - $currentWidgetName = $paragraph->get(self::WIDGET_FIELD_NAME)->value; - $newWidgetName = self::WIDGET_MAP[$currentWidgetName]; - if (!isset(self::WIDGET_MAP[$currentWidgetName])) { - return "New widget name not found for paragraph id {$item} with widget name {$currentWidgetName}. Skipping."; + // Update current node. + $this->batchOpLog->appendLog($this->updateWidget($node)); + return "Done processing {$node->id()}"; + } + + /** + * Determines if the given node has the necessary React widget. + * + * @return bool + * TRUE if the widget is present on the node. + */ + private function hasWidget(NodeInterface $node):bool { + // The widget will always be in field field_content_block as a paragraph. + /** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $item */ + foreach ($node->get('field_content_block') as $item) { + /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ + $paragraph = $item->entity; + if ($paragraph->bundle() === 'react_widget') { + if (in_array($paragraph->get(self::WIDGET_FIELD_NAME)->value, array_keys(self::WIDGET_MAP))) { + return TRUE; + } } - // Set the name of this widget to the new MHV widget name. - $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); - $paragraph->save(); - // Get the path alias for this node for logging. - $alias = $this->pathAliasManager->getAliasByPath('/node/' . $parentEntity->id()); - return "Updated from {$currentWidgetName} to {$newWidgetName} id {$item} for node id {$parentEntity->id()} having path alias of {$alias}"; } - catch (EntityStorageException $e) { - return "There was an error saving paragraph id {$item}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"; + return FALSE; + } + + /** + * Updates the node's React widget to the modern name. + * + * @param \Drupal\node\NodeInterface $node + * The node to update. + * + * @return string + * The message indicating the action taken when updating. + * + * @throws \Drupal\Core\Entity\EntityMalformedException + * Thrown if the toUrl() could not find an entity id. + */ + private function updateWidget(NodeInterface $node): string { + $path = $node->toUrl()->toString(); + $revisionId = $node->getRevisionId(); + $nodeMessage = "Node {$node->id()} revision {$revisionId} at {$path}"; + // Store message for each widget we find. Some nodes may have multiple. + $foundWidgets = []; + // The widget will always be in field field_content_block as a paragraph. + /** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $item */ + foreach ($node->get('field_content_block') as $item) { + /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ + $paragraph = $item->entity; + if ($paragraph->bundle() === 'react_widget') { + $currentWidgetName = $paragraph->get(self::WIDGET_FIELD_NAME)->value; + if (in_array($currentWidgetName, array_keys(self::WIDGET_MAP))) { + try { + $newWidgetName = self::WIDGET_MAP[$currentWidgetName]; + // @todo remove this before pushing. + if (!self::DEBUG) { + // Set the name of this widget to the new MHV widget name. + $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); + $paragraph->save(); + } + $foundWidgets[] = $nodeMessage . ": updated widget from {$currentWidgetName} to {$newWidgetName} in paragraph id {$paragraph->id()}"; + } + catch (EntityStorageException $e) { + return "Error saving paragraph id {$paragraph->id()}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"; + } + } + else { + $foundWidgets[] = $nodeMessage . " has a React widget {$currentWidgetName} but it is not in target list."; + } + } } + array_walk($foundWidgets, fn($message) => $this->batchOpLog->appendLog($message)); + return $nodeMessage . " finished widget updates."; } } From 6097464c1ba22a57067dfc1aa0d7c6e832277c2d Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:46:25 -0800 Subject: [PATCH 4/6] VACMS-20726: Remove debug code. --- .../ReactWidgetUpdatesForMHVMigration.php | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php index 28cf48fcfd..1ce8df98e4 100644 --- a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -43,15 +43,6 @@ class ReactWidgetUpdatesForMHVMigration extends BatchOperations implements Batch */ const DATA_FILE_LOCATION = __DIR__ . '/../../data/NodesForMHVReactWidgetMigration.csv'; - /** - * Enable for debugging. Prevents updating paragraphs. - * - * @todo Remove before pushing. - * - * @var bool - */ - const DEBUG = TRUE; - /** * {@inheritdoc} */ @@ -120,19 +111,14 @@ public function processOne(string $key, mixed $item, array &$sandbox): string { if (!$node) { return "There was a problem loading node id {$item}. Further investigation is needed. Skipping."; } - $path = $node->toUrl()->toString(); - $nodeMessage = "Node {$node->id()} at {$path}"; - // Note unpublished nodes. We may leave these alone. TBD. Skipping for now. if (!$node->isPublished()) { $state = $node->get('moderation_state')->value; $widgetStatus = 'has ' . ($this->hasWidget($node) ? 'a React widget' : 'no React widget'); - return $nodeMessage . " is not published. It's current status is {$state} and it {$widgetStatus}. Skipping"; + return "{$node->getTitle()}:{$path}: Node is not published. It's current status is {$state} and it {$widgetStatus}. Skipping"; } - // Update current node. - $this->batchOpLog->appendLog($this->updateWidget($node)); - return "Done processing {$node->id()}"; + return $this->updateWidget($node); } /** @@ -170,8 +156,7 @@ private function hasWidget(NodeInterface $node):bool { */ private function updateWidget(NodeInterface $node): string { $path = $node->toUrl()->toString(); - $revisionId = $node->getRevisionId(); - $nodeMessage = "Node {$node->id()} revision {$revisionId} at {$path}"; + $nodeMessage = "node_{$node->id()}: {$node->getTitle()}:{$path}: "; // Store message for each widget we find. Some nodes may have multiple. $foundWidgets = []; // The widget will always be in field field_content_block as a paragraph. @@ -184,25 +169,22 @@ private function updateWidget(NodeInterface $node): string { if (in_array($currentWidgetName, array_keys(self::WIDGET_MAP))) { try { $newWidgetName = self::WIDGET_MAP[$currentWidgetName]; - // @todo remove this before pushing. - if (!self::DEBUG) { - // Set the name of this widget to the new MHV widget name. - $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); - $paragraph->save(); - } - $foundWidgets[] = $nodeMessage . ": updated widget from {$currentWidgetName} to {$newWidgetName} in paragraph id {$paragraph->id()}"; + // Update the name of this widget to the new MHV widget name. + $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); + $paragraph->save(); + $foundWidgets[] = $nodeMessage . "updated widget from {$currentWidgetName} to {$newWidgetName} in paragraph id {$paragraph->id()}"; } catch (EntityStorageException $e) { return "Error saving paragraph id {$paragraph->id()}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"; } } else { - $foundWidgets[] = $nodeMessage . " has a React widget {$currentWidgetName} but it is not in target list."; + $foundWidgets[] = $nodeMessage . "node has a React widget {$currentWidgetName} but it is not in target list."; } } } array_walk($foundWidgets, fn($message) => $this->batchOpLog->appendLog($message)); - return $nodeMessage . " finished widget updates."; + return "Finished widget updates."; } } From d3d02ca7fdf43a58b6c65a2a427193c1485bf06e Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:42:10 -0800 Subject: [PATCH 5/6] VACMS-20726: Remove special handling of the unpublished nodes. --- .../ReactWidgetUpdatesForMHVMigration.php | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php index 1ce8df98e4..cde04420f1 100644 --- a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -111,37 +111,9 @@ public function processOne(string $key, mixed $item, array &$sandbox): string { if (!$node) { return "There was a problem loading node id {$item}. Further investigation is needed. Skipping."; } - $path = $node->toUrl()->toString(); - // Note unpublished nodes. We may leave these alone. TBD. Skipping for now. - if (!$node->isPublished()) { - $state = $node->get('moderation_state')->value; - $widgetStatus = 'has ' . ($this->hasWidget($node) ? 'a React widget' : 'no React widget'); - return "{$node->getTitle()}:{$path}: Node is not published. It's current status is {$state} and it {$widgetStatus}. Skipping"; - } return $this->updateWidget($node); } - /** - * Determines if the given node has the necessary React widget. - * - * @return bool - * TRUE if the widget is present on the node. - */ - private function hasWidget(NodeInterface $node):bool { - // The widget will always be in field field_content_block as a paragraph. - /** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $item */ - foreach ($node->get('field_content_block') as $item) { - /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */ - $paragraph = $item->entity; - if ($paragraph->bundle() === 'react_widget') { - if (in_array($paragraph->get(self::WIDGET_FIELD_NAME)->value, array_keys(self::WIDGET_MAP))) { - return TRUE; - } - } - } - return FALSE; - } - /** * Updates the node's React widget to the modern name. * From b5bff4b4e7a02b5466fff0823a00f9115bd3b5fb Mon Sep 17 00:00:00 2001 From: Daniel Sasser <221539+dsasser@users.noreply.github.com> Date: Fri, 7 Mar 2025 08:01:45 -0800 Subject: [PATCH 6/6] VACMS-20726: Change the behavior of logging widget updates so it is more clear which nodes get updates and which do not. --- .../ReactWidgetUpdatesForMHVMigration.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php index cde04420f1..02ba46085a 100644 --- a/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php +++ b/docroot/modules/custom/va_gov_batch/src/cbo_scripts/ReactWidgetUpdatesForMHVMigration.php @@ -129,8 +129,9 @@ public function processOne(string $key, mixed $item, array &$sandbox): string { private function updateWidget(NodeInterface $node): string { $path = $node->toUrl()->toString(); $nodeMessage = "node_{$node->id()}: {$node->getTitle()}:{$path}: "; - // Store message for each widget we find. Some nodes may have multiple. - $foundWidgets = []; + // Store message for each widget we update. While unlikely that a node will + // have multiple widgets, we need to ensure we are not missing any updates. + $updates = []; // The widget will always be in field field_content_block as a paragraph. /** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $item */ foreach ($node->get('field_content_block') as $item) { @@ -144,19 +145,25 @@ private function updateWidget(NodeInterface $node): string { // Update the name of this widget to the new MHV widget name. $paragraph->set(self::WIDGET_FIELD_NAME, $newWidgetName); $paragraph->save(); - $foundWidgets[] = $nodeMessage . "updated widget from {$currentWidgetName} to {$newWidgetName} in paragraph id {$paragraph->id()}"; + $updates[] = $nodeMessage . "updated widget from {$currentWidgetName} to {$newWidgetName} in paragraph id {$paragraph->id()}"; } catch (EntityStorageException $e) { - return "Error saving paragraph id {$paragraph->id()}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"; + $this->batchOpLog->appendError($nodeMessage . "Error saving paragraph id {$paragraph->id()}. This is unexpected and manual migration may be required. The error was {$e->getMessage()}"); } } else { - $foundWidgets[] = $nodeMessage . "node has a React widget {$currentWidgetName} but it is not in target list."; + $this->batchOpLog->appendLog($nodeMessage . "node has a React widget {$currentWidgetName} but it is not in target list."); } } } - array_walk($foundWidgets, fn($message) => $this->batchOpLog->appendLog($message)); - return "Finished widget updates."; + if (count($updates) > 0) { + array_walk($updates, fn($message) => $this->batchOpLog->appendLog($message)); + $count = count($updates); + return $nodeMessage . "{$count} widget update(s) made."; + } + else { + return $nodeMessage . "no widget updates were made."; + } } }