From a3583b8edcdb397325808b9c63ff3c3fee5b864b Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Wed, 28 Aug 2024 13:19:32 -0600 Subject: [PATCH 1/5] Release 11.4.2: Update pathauto for nodes and terms --- .../engineering_profile_helper.install | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/engineering_profile_helper/engineering_profile_helper.install b/modules/engineering_profile_helper/engineering_profile_helper.install index 80924be3..d54ea2b0 100644 --- a/modules/engineering_profile_helper/engineering_profile_helper.install +++ b/modules/engineering_profile_helper/engineering_profile_helper.install @@ -6,6 +6,7 @@ */ use Drupal\redirect\Entity\Redirect; +use Drupal\pathauto\PathautoState; /** * Fix broken manual redirect loops. @@ -32,3 +33,32 @@ function engineering_profile_helper_update_9001() { } } + +/** + * Update hook to set nodes to automatically generate URL aliases. + */ +function engineering_profile_helper_update_9002() { + + $entity_type = 'node'; + $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); + $nodes = $entity_storage->loadMultiple(); + foreach($nodes as $node) { + $bundles = ['stanford_page', 'stanford_news', 'spotlight']; + if (in_array($node->bundle(), $bundles) && !$node->path->pathauto) { + $node->path->pathauto = PathautoState::CREATE; + $node->save(); + } + } + + $entity_type = 'taxonomy_term'; + $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); + $terms = $entity_storage->loadMultiple(); + foreach($terms as $term) { + if (!$term->path->pathauto) { + $term->path->pathauto = PathautoState::CREATE; + $term->save(); + } + } + + \Drupal::logger('mymodule')->info('Updated URL alias settings for stanford_page, spotlight, and stanford_news nodes that were not set to generate automatically.'); +} From 6466425b297f220f07587b1be9576177158a6bd8 Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Wed, 28 Aug 2024 14:07:27 -0600 Subject: [PATCH 2/5] refactored to drush command --- .../engineering_profile_helper/composer.json | 9 +++- .../drush.services.yml | 5 ++ .../EngineeringProfileHelperCommands.php | 47 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 modules/engineering_profile_helper/drush.services.yml create mode 100644 modules/engineering_profile_helper/src/Commands/EngineeringProfileHelperCommands.php diff --git a/modules/engineering_profile_helper/composer.json b/modules/engineering_profile_helper/composer.json index 3de81093..1d4d5260 100644 --- a/modules/engineering_profile_helper/composer.json +++ b/modules/engineering_profile_helper/composer.json @@ -3,5 +3,12 @@ "type": "drupal-module", "description": "Engineering Profile Helper module", "keywords": [], - "minimum-stability": "dev" + "minimum-stability": "dev", + "extra": { + "drush": { + "services": { + "drush.services.yml": "^9" + } + } + } } diff --git a/modules/engineering_profile_helper/drush.services.yml b/modules/engineering_profile_helper/drush.services.yml new file mode 100644 index 00000000..78127662 --- /dev/null +++ b/modules/engineering_profile_helper/drush.services.yml @@ -0,0 +1,5 @@ +services: + my_module.commands: + class: Drupal\engineering_profile_helper\Commands\EngineeringProfileHelperCommands + tags: + - { name: drush.command } diff --git a/modules/engineering_profile_helper/src/Commands/EngineeringProfileHelperCommands.php b/modules/engineering_profile_helper/src/Commands/EngineeringProfileHelperCommands.php new file mode 100644 index 00000000..92e9377e --- /dev/null +++ b/modules/engineering_profile_helper/src/Commands/EngineeringProfileHelperCommands.php @@ -0,0 +1,47 @@ +getStorage($entity_type); + $nodes = $entity_storage->loadMultiple(); + foreach ($nodes as $node) { + $bundles = ['stanford_page', 'stanford_news', 'spotlight']; + if (in_array($node->bundle(), $bundles) && !$node->path->pathauto) { + $node->path->pathauto = PathautoState::CREATE; + $node->save(); + } + } + + $entity_type = 'taxonomy_term'; + $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); + $terms = $entity_storage->loadMultiple(); + foreach ($terms as $term) { + if (!$term->path->pathauto) { + $term->path->pathauto = PathautoState::CREATE; + $term->save(); + } + } + + $this->logger()->success('Updated URL alias settings for stanford_page, spotlight, and stanford_news nodes and all taxonomy terms that were not set to generate automatically.'); + } + +} From 9a44334bfc053eff3b9691f2f22c8f7993a895cb Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Wed, 28 Aug 2024 15:54:15 -0600 Subject: [PATCH 3/5] Removed update hook in favor of Drush command --- .../engineering_profile_helper.install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/engineering_profile_helper/engineering_profile_helper.install b/modules/engineering_profile_helper/engineering_profile_helper.install index d54ea2b0..4943b2ae 100644 --- a/modules/engineering_profile_helper/engineering_profile_helper.install +++ b/modules/engineering_profile_helper/engineering_profile_helper.install @@ -36,7 +36,7 @@ function engineering_profile_helper_update_9001() { /** * Update hook to set nodes to automatically generate URL aliases. - */ + function engineering_profile_helper_update_9002() { $entity_type = 'node'; @@ -62,3 +62,4 @@ function engineering_profile_helper_update_9002() { \Drupal::logger('mymodule')->info('Updated URL alias settings for stanford_page, spotlight, and stanford_news nodes that were not set to generate automatically.'); } + */ From 66660f0730f1fdcec014e7593c8bff6b00642e3e Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Thu, 26 Sep 2024 11:41:55 -0600 Subject: [PATCH 4/5] Release 11.4.3: Changed label on news subnav --- .../engineering_profile_helper.install | 30 ------------------- .../block/magazine-navigation.html.twig | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/modules/engineering_profile_helper/engineering_profile_helper.install b/modules/engineering_profile_helper/engineering_profile_helper.install index 4943b2ae..fe92536c 100644 --- a/modules/engineering_profile_helper/engineering_profile_helper.install +++ b/modules/engineering_profile_helper/engineering_profile_helper.install @@ -33,33 +33,3 @@ function engineering_profile_helper_update_9001() { } } - -/** - * Update hook to set nodes to automatically generate URL aliases. - -function engineering_profile_helper_update_9002() { - - $entity_type = 'node'; - $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); - $nodes = $entity_storage->loadMultiple(); - foreach($nodes as $node) { - $bundles = ['stanford_page', 'stanford_news', 'spotlight']; - if (in_array($node->bundle(), $bundles) && !$node->path->pathauto) { - $node->path->pathauto = PathautoState::CREATE; - $node->save(); - } - } - - $entity_type = 'taxonomy_term'; - $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); - $terms = $entity_storage->loadMultiple(); - foreach($terms as $term) { - if (!$term->path->pathauto) { - $term->path->pathauto = PathautoState::CREATE; - $term->save(); - } - } - - \Drupal::logger('mymodule')->info('Updated URL alias settings for stanford_page, spotlight, and stanford_news nodes that were not set to generate automatically.'); -} - */ diff --git a/modules/engineering_profile_helper/modules/engineering_magazine/templates/block/magazine-navigation.html.twig b/modules/engineering_profile_helper/modules/engineering_magazine/templates/block/magazine-navigation.html.twig index a25e6c22..a1f02cfe 100644 --- a/modules/engineering_profile_helper/modules/engineering_magazine/templates/block/magazine-navigation.html.twig +++ b/modules/engineering_profile_helper/modules/engineering_magazine/templates/block/magazine-navigation.html.twig @@ -24,7 +24,7 @@ Profile magazine_navigation_block - + From 76564ba1ab7e107b3bb785465f3bc354c6aa6bd6 Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Thu, 26 Sep 2024 12:04:06 -0600 Subject: [PATCH 5/5] updated info.yml --- engineering_profile.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engineering_profile.info.yml b/engineering_profile.info.yml index cac9413d..32b7b5be 100644 --- a/engineering_profile.info.yml +++ b/engineering_profile.info.yml @@ -1,6 +1,6 @@ name: "SOE Profile" description: 'Jumpstart Website Profile' -version: 11.4.1 +version: 11.4.3 type: profile project: Stanford core_version_requirement: ^9 || ^10