Skip to content

Commit

Permalink
Close #2800 Update Global Footer with new X/Twitter Icon. (#3056)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Parsons <[email protected]>
Co-authored-by: bberndt-uaz <[email protected]>
Co-authored-by: Chris Green <[email protected]>
Co-authored-by: Dana Hertzberg <[email protected]>
  • Loading branch information
5 people committed Jan 17, 2024
1 parent 8cb95aa commit 4dbeba3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
49 changes: 49 additions & 0 deletions modules/custom/az_global_footer/az_global_footer.install
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,52 @@ function az_global_footer_update_1020703() {

return t('Updated %count menu link(s) from A-Z Index to Directory in the global footer.', ['%count' => $updated_count]);
}

/**
* Update Twitter link(s) to new X link(s)
*
* Twitter icon(s) in the global footer will be updated with
* new X icon(s).
*/
function az_global_footer_update_1020801() {
$updated_count = 0;
$menu_link_content_ids = \Drupal::entityQuery('menu_link_content')
->accessCheck(FALSE)
->condition('menu_name', 'az-footer-social-media')
->condition('title', 'Twitter')
->condition('link__uri', 'https://twitter.com/uarizona')
->execute();

foreach ($menu_link_content_ids as $id) {
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link_content */
$menu_link_content = MenuLinkContent::load($id);

if ($menu_link_content !== NULL) {
// phpcs:disable
/* @phpstan-ignore-next-line */
$menu_link_content->title = 'X, formerly Twitter';
/* @phpstan-ignore-next-line */
$menu_link_content->link->uri = 'https://x.com/uarizona';

// Retrieve existing options
/* @phpstan-ignore-next-line */
$options = $menu_link_content->link->first()->options;

// Set new classes
$options['attributes']['class'] = [
'az-icon-x-twitter',
'az-icon-spacing'
];

// Update the options
/* @phpstan-ignore-next-line */
$menu_link_content->link->first()->options = $options;

// phpcs:enable
$menu_link_content->save();
$updated_count++;
}
}

return t('Updated %count X-Twitter link(s) & icon(s) in the global footer.', ['%count' => $updated_count]);
}
6 changes: 3 additions & 3 deletions modules/custom/az_global_footer/data/az_global_footer.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,14 @@
"link_id": "36",
"parent_link_id": "0",
"menu": "az-footer-social-media",
"title": "Twitter",
"urlpath": "https://twitter.com/uarizona",
"title": "X, formerly Twitter",
"urlpath": "https://x.com/uarizona",
"external": true,
"expanded": false,
"enabled": true,
"weight": "2",
"class": [
"az-icon-twitter",
"az-icon-x-twitter",
"az-icon-spacing"
]
},
Expand Down

0 comments on commit 4dbeba3

Please sign in to comment.