From be1cf5819afb7f327d2b94251262ec6efad41ade Mon Sep 17 00:00:00 2001 From: Chris Green Date: Wed, 11 Dec 2024 16:49:39 -0700 Subject: [PATCH 01/14] Fixes #3944 Whitescreen if az_person not enabled. --- modules/custom/az_core/az_core.services.yml | 1 + .../az_core/src/AZUserToolbarLinkBuilder.php | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/custom/az_core/az_core.services.yml b/modules/custom/az_core/az_core.services.yml index 7a7f676e9c..8899f46d40 100755 --- a/modules/custom/az_core/az_core.services.yml +++ b/modules/custom/az_core/az_core.services.yml @@ -34,3 +34,4 @@ services: arguments: - '@entity_type.manager' - '@?externalauth.authmap' + - '@module_handler' diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index d1e5dc9d83..0c0bec5f25 100644 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -3,6 +3,7 @@ namespace Drupal\az_core; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Url; use Drupal\externalauth\AuthmapInterface; @@ -27,6 +28,13 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { */ protected $entityTypeManager; + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + /** * ToolbarHandler constructor. * @@ -36,11 +44,14 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { * The entity type manager. * @param \Drupal\externalauth\AuthmapInterface $authmap * The authmap service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler + * The module handler. */ - public function __construct(AccountProxyInterface $account, EntityTypeManagerInterface $entityTypeManager, ?AuthmapInterface $authmap) { + public function __construct(AccountProxyInterface $account, EntityTypeManagerInterface $entityTypeManager, ?AuthmapInterface $authmap, ModuleHandlerInterface $moduleHandler) { parent::__construct($account); $this->entityTypeManager = $entityTypeManager; $this->authmap = $authmap; + $this->moduleHandler = $moduleHandler; } /** @@ -51,9 +62,11 @@ public function __construct(AccountProxyInterface $account, EntityTypeManagerInt */ public function renderToolbarLinks() { $build = parent::renderToolbarLinks(); + // Check if the az_person module is enabled. + $az_person_enabled = $this->moduleHandler->moduleExists('az_person'); $additional_links = []; // Only valid if we have the externalauth module. - if (!empty($this->authmap)) { + if (!empty($this->authmap) && $az_person_enabled) { // Check if we have permission. if ($this->account->hasPermission('edit matching netid content')) { $auth = $this->authmap->get($this->account->id(), 'cas'); From f95f0475b7af5f3432d4cf96f346da057b9d501c Mon Sep 17 00:00:00 2001 From: Joe Parsons <471936+joeparsons@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:09:29 -0700 Subject: [PATCH 02/14] Update modules/custom/az_core/src/AZUserToolbarLinkBuilder.php --- modules/custom/az_core/src/AZUserToolbarLinkBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index 0c0bec5f25..b9f157c112 100644 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -45,7 +45,7 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { * @param \Drupal\externalauth\AuthmapInterface $authmap * The authmap service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler - * The module handler. + * The module handler. */ public function __construct(AccountProxyInterface $account, EntityTypeManagerInterface $entityTypeManager, ?AuthmapInterface $authmap, ModuleHandlerInterface $moduleHandler) { parent::__construct($account); From 3a5c031781069882ceeab21140ef0763f47de597 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 09:33:33 -0700 Subject: [PATCH 03/14] Move the service to az_person. --- modules/custom/az_core/az_core.services.yml | 11 -- .../custom/az_person/az_person.services.yml | 14 +++ .../src/AZUserToolbarLinkBuilder.php | 107 ++++++++++++++++++ 3 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 modules/custom/az_person/az_person.services.yml create mode 100644 modules/custom/az_person/src/AZUserToolbarLinkBuilder.php diff --git a/modules/custom/az_core/az_core.services.yml b/modules/custom/az_core/az_core.services.yml index 8899f46d40..7140618f19 100755 --- a/modules/custom/az_core/az_core.services.yml +++ b/modules/custom/az_core/az_core.services.yml @@ -24,14 +24,3 @@ services: - '@config_sync.snapshotter' - '@config_update.config_list' - '@module_handler' - # Decorates the normal user module links. - az_core.toolbar_link_builder: - class: Drupal\az_core\AZUserToolbarLinkBuilder - decorates: user.toolbar_link_builder - parent: user.toolbar_link_builder - # Append arguments to parent service arguments. - # externalauth.authmap declared optional because CAS may or may not be enabled. - arguments: - - '@entity_type.manager' - - '@?externalauth.authmap' - - '@module_handler' diff --git a/modules/custom/az_person/az_person.services.yml b/modules/custom/az_person/az_person.services.yml new file mode 100644 index 0000000000..c1202cad1b --- /dev/null +++ b/modules/custom/az_person/az_person.services.yml @@ -0,0 +1,14 @@ +services: + _defaults: + autowire: true + autoconfigure: true + # Decorates the normal user module links. + az_person.toolbar_link_builder: + class: Drupal\az_person\AZUserToolbarLinkBuilder + decorates: user.toolbar_link_builder + parent: user.toolbar_link_builder + # Append arguments to parent service arguments. + # externalauth.authmap declared optional because CAS may or may not be enabled. + arguments: + - '@entity_type.manager' + - '@?externalauth.authmap' diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php new file mode 100644 index 0000000000..c5edd73b35 --- /dev/null +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -0,0 +1,107 @@ +entityTypeManager = $entityTypeManager; + $this->authmap = $authmap; + } + + /** + * Lazy builder callback for rendering toolbar links. + * + * @return array + * A renderable array as expected by the renderer service. + */ + public function renderToolbarLinks() { + $build = parent::renderToolbarLinks(); + $additional_links = []; + // Only valid if we have the externalauth module. + if (!empty($this->authmap)) { + // Check if we have permission. + if ($this->account->hasPermission('edit matching netid content')) { + $auth = $this->authmap->get($this->account->id(), 'cas'); + if (($auth !== FALSE)) { + // Check if we have a linked person. + $persons = $this->entityTypeManager->getStorage('node')->loadByProperties([ + 'field_az_netid' => $auth, + 'type' => 'az_person', + 'status' => [1, TRUE], + ]); + if (!empty($persons)) { + $person = reset($persons); + // If we have a linked az person, generate links. + $additional_links = [ + 'az_person' => [ + 'title' => $this->t('View my web page'), + 'url' => Url::fromRoute('entity.node.canonical', ['node' => $person->id()]), + 'attributes' => [ + 'title' => $this->t('View my web page'), + ], + ], + 'az_person_edit' => [ + 'title' => $this->t('Edit my web page'), + 'url' => Url::fromRoute('entity.node.edit_form', ['node' => $person->id()]), + 'attributes' => [ + 'title' => $this->t('Edit my web page'), + ], + ], + ]; + } + } + } + } + // Transform some of the user module links for clarity. + if (!empty($build['#links'])) { + $original_links = $build['#links']; + if (!empty($original_links['account'])) { + $original_links['account']['title'] = $this->t('View user account'); + } + if (!empty($original_links['account_edit'])) { + $original_links['account_edit']['title'] = $this->t('Edit user account'); + } + // Add in our links among the user module links. + $links = array_merge($additional_links, $original_links); + $build['#links'] = $links; + } + return $build; + } + +} From e641cfc655de85aa440cefa43239a88bcf696ad2 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 09:46:35 -0700 Subject: [PATCH 04/14] Remove duplicate file --- .../az_core/src/AZUserToolbarLinkBuilder.php | 119 ------------------ 1 file changed, 119 deletions(-) delete mode 100644 modules/custom/az_core/src/AZUserToolbarLinkBuilder.php diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php deleted file mode 100644 index b9f157c112..0000000000 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ /dev/null @@ -1,119 +0,0 @@ -entityTypeManager = $entityTypeManager; - $this->authmap = $authmap; - $this->moduleHandler = $moduleHandler; - } - - /** - * Lazy builder callback for rendering toolbar links. - * - * @return array - * A renderable array as expected by the renderer service. - */ - public function renderToolbarLinks() { - $build = parent::renderToolbarLinks(); - // Check if the az_person module is enabled. - $az_person_enabled = $this->moduleHandler->moduleExists('az_person'); - $additional_links = []; - // Only valid if we have the externalauth module. - if (!empty($this->authmap) && $az_person_enabled) { - // Check if we have permission. - if ($this->account->hasPermission('edit matching netid content')) { - $auth = $this->authmap->get($this->account->id(), 'cas'); - if (($auth !== FALSE)) { - // Check if we have a linked person. - $persons = $this->entityTypeManager->getStorage('node')->loadByProperties([ - 'field_az_netid' => $auth, - 'type' => 'az_person', - 'status' => [1, TRUE], - ]); - if (!empty($persons)) { - $person = reset($persons); - // If we have a linked az person, generate links. - $additional_links = [ - 'az_person' => [ - 'title' => $this->t('View my web page'), - 'url' => Url::fromRoute('entity.node.canonical', ['node' => $person->id()]), - 'attributes' => [ - 'title' => $this->t('View my web page'), - ], - ], - 'az_person_edit' => [ - 'title' => $this->t('Edit my web page'), - 'url' => Url::fromRoute('entity.node.edit_form', ['node' => $person->id()]), - 'attributes' => [ - 'title' => $this->t('Edit my web page'), - ], - ], - ]; - } - } - } - } - // Transform some of the user module links for clarity. - if (!empty($build['#links'])) { - $original_links = $build['#links']; - if (!empty($original_links['account'])) { - $original_links['account']['title'] = $this->t('View user account'); - } - if (!empty($original_links['account_edit'])) { - $original_links['account_edit']['title'] = $this->t('Edit user account'); - } - // Add in our links among the user module links. - $links = array_merge($additional_links, $original_links); - $build['#links'] = $links; - } - return $build; - } - -} From 604dca14de724dcd823a2dbc24e2e6ac5144a467 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 09:47:17 -0700 Subject: [PATCH 05/14] Remove unused use statement --- modules/custom/az_person/src/AZUserToolbarLinkBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php index c5edd73b35..d7ebfd9b46 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -3,7 +3,6 @@ namespace Drupal\az_person; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Url; use Drupal\externalauth\AuthmapInterface; From 393aef935e8632c01c4a13588e58892f3bc94841 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 09:59:24 -0700 Subject: [PATCH 06/14] Check if field exists on person entity --- .../custom/az_person/az_person.services.yml | 1 + .../src/AZUserToolbarLinkBuilder.php | 76 +++++++++++++------ 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/modules/custom/az_person/az_person.services.yml b/modules/custom/az_person/az_person.services.yml index c1202cad1b..e3d603cf4e 100644 --- a/modules/custom/az_person/az_person.services.yml +++ b/modules/custom/az_person/az_person.services.yml @@ -11,4 +11,5 @@ services: # externalauth.authmap declared optional because CAS may or may not be enabled. arguments: - '@entity_type.manager' + - '@entity_field.manager' - '@?externalauth.authmap' diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php index d7ebfd9b46..72d069b096 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -2,6 +2,7 @@ namespace Drupal\az_person; +use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Url; @@ -14,19 +15,26 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { /** - * Drupal\externalauth\AuthmapInterface definition. + * Authmap service definition. * * @var \Drupal\externalauth\AuthmapInterface */ protected $authmap; /** - * Drupal\Core\Entity\EntityTypeManagerInterface definition. + * Entity type manager service definition. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; + /** + * Entity field manager service definition. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + /** * ToolbarHandler constructor. * @@ -34,12 +42,20 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { * The current user. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager * The entity type manager. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager + * The entity field manager. * @param \Drupal\externalauth\AuthmapInterface $authmap * The authmap service. */ - public function __construct(AccountProxyInterface $account, EntityTypeManagerInterface $entityTypeManager, ?AuthmapInterface $authmap) { + public function __construct( + AccountProxyInterface $account, + EntityTypeManagerInterface $entityTypeManager, + EntityFieldManagerInterface $entityFieldManager, + ?AuthmapInterface $authmap + ) { parent::__construct($account); $this->entityTypeManager = $entityTypeManager; + $this->entityFieldManager = $entityFieldManager; $this->authmap = $authmap; } @@ -52,41 +68,50 @@ public function __construct(AccountProxyInterface $account, EntityTypeManagerInt public function renderToolbarLinks() { $build = parent::renderToolbarLinks(); $additional_links = []; + // Only valid if we have the externalauth module. if (!empty($this->authmap)) { // Check if we have permission. if ($this->account->hasPermission('edit matching netid content')) { $auth = $this->authmap->get($this->account->id(), 'cas'); - if (($auth !== FALSE)) { - // Check if we have a linked person. - $persons = $this->entityTypeManager->getStorage('node')->loadByProperties([ - 'field_az_netid' => $auth, - 'type' => 'az_person', - 'status' => [1, TRUE], - ]); - if (!empty($persons)) { - $person = reset($persons); - // If we have a linked az person, generate links. - $additional_links = [ - 'az_person' => [ - 'title' => $this->t('View my web page'), - 'url' => Url::fromRoute('entity.node.canonical', ['node' => $person->id()]), - 'attributes' => [ + + if ($auth !== FALSE && is_string($auth)) { + // Verify that 'field_az_netid' exists for 'az_person' content type. + $field_definitions = $this->entityFieldManager->getFieldDefinitions('node', 'az_person'); + + if (isset($field_definitions['field_az_netid'])) { + // Check if we have a linked person. + $persons = $this->entityTypeManager->getStorage('node')->loadByProperties([ + 'field_az_netid' => $auth, + 'type' => 'az_person', + 'status' => [1, TRUE], + ]); + + if (!empty($persons)) { + $person = reset($persons); + // If we have a linked az person, generate links. + $additional_links = [ + 'az_person' => [ 'title' => $this->t('View my web page'), + 'url' => Url::fromRoute('entity.node.canonical', ['node' => $person->id()]), + 'attributes' => [ + 'title' => $this->t('View my web page'), + ], ], - ], - 'az_person_edit' => [ - 'title' => $this->t('Edit my web page'), - 'url' => Url::fromRoute('entity.node.edit_form', ['node' => $person->id()]), - 'attributes' => [ + 'az_person_edit' => [ 'title' => $this->t('Edit my web page'), + 'url' => Url::fromRoute('entity.node.edit_form', ['node' => $person->id()]), + 'attributes' => [ + 'title' => $this->t('Edit my web page'), + ], ], - ], - ]; + ]; + } } } } } + // Transform some of the user module links for clarity. if (!empty($build['#links'])) { $original_links = $build['#links']; @@ -100,6 +125,7 @@ public function renderToolbarLinks() { $links = array_merge($additional_links, $original_links); $build['#links'] = $links; } + return $build; } From 372eeaf0aa9a4da3ddaba00c12f38cbe71bc8513 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 10:02:47 -0700 Subject: [PATCH 07/14] Check if field exists on person entity --- modules/custom/az_person/src/AZUserToolbarLinkBuilder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php index 72d069b096..b9dcc87c0a 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -75,10 +75,9 @@ public function renderToolbarLinks() { if ($this->account->hasPermission('edit matching netid content')) { $auth = $this->authmap->get($this->account->id(), 'cas'); - if ($auth !== FALSE && is_string($auth)) { + if (($auth !== FALSE)) { // Verify that 'field_az_netid' exists for 'az_person' content type. $field_definitions = $this->entityFieldManager->getFieldDefinitions('node', 'az_person'); - if (isset($field_definitions['field_az_netid'])) { // Check if we have a linked person. $persons = $this->entityTypeManager->getStorage('node')->loadByProperties([ From 287cda4aa73fa2e4da3442640de7d19cea6bcfec Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 10:04:03 -0700 Subject: [PATCH 08/14] Check if field exists on person entity --- modules/custom/az_person/src/AZUserToolbarLinkBuilder.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php index b9dcc87c0a..4fdbb0974e 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -68,13 +68,11 @@ public function __construct( public function renderToolbarLinks() { $build = parent::renderToolbarLinks(); $additional_links = []; - // Only valid if we have the externalauth module. if (!empty($this->authmap)) { // Check if we have permission. if ($this->account->hasPermission('edit matching netid content')) { $auth = $this->authmap->get($this->account->id(), 'cas'); - if (($auth !== FALSE)) { // Verify that 'field_az_netid' exists for 'az_person' content type. $field_definitions = $this->entityFieldManager->getFieldDefinitions('node', 'az_person'); @@ -85,7 +83,6 @@ public function renderToolbarLinks() { 'type' => 'az_person', 'status' => [1, TRUE], ]); - if (!empty($persons)) { $person = reset($persons); // If we have a linked az person, generate links. From 0b9dda89483c088060cb0402842895a0bf5026d4 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 10:07:48 -0700 Subject: [PATCH 09/14] Update modules/custom/az_person/src/AZUserToolbarLinkBuilder.php --- modules/custom/az_person/src/AZUserToolbarLinkBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php index 4fdbb0974e..74f0ba7cff 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php @@ -51,7 +51,7 @@ public function __construct( AccountProxyInterface $account, EntityTypeManagerInterface $entityTypeManager, EntityFieldManagerInterface $entityFieldManager, - ?AuthmapInterface $authmap + ?AuthmapInterface $authmap, ) { parent::__construct($account); $this->entityTypeManager = $entityTypeManager; From 62aeac754f8e6841ca8a9509d1293452a942040a Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 10:46:42 -0700 Subject: [PATCH 10/14] Moving service back to core --- modules/custom/az_core/az_core.services.yml | 11 +++++++++++ .../src/AZUserToolbarLinkBuilder.php | 15 +-------------- modules/custom/az_person/az_person.services.yml | 15 --------------- 3 files changed, 12 insertions(+), 29 deletions(-) rename modules/custom/{az_person => az_core}/src/AZUserToolbarLinkBuilder.php (85%) delete mode 100644 modules/custom/az_person/az_person.services.yml diff --git a/modules/custom/az_core/az_core.services.yml b/modules/custom/az_core/az_core.services.yml index 7140618f19..1e7e2f1a5d 100755 --- a/modules/custom/az_core/az_core.services.yml +++ b/modules/custom/az_core/az_core.services.yml @@ -24,3 +24,14 @@ services: - '@config_sync.snapshotter' - '@config_update.config_list' - '@module_handler' + # Decorates the normal user module links. + az_person.toolbar_link_builder: + class: Drupal\az_core\AZUserToolbarLinkBuilder + decorates: user.toolbar_link_builder + parent: user.toolbar_link_builder + # Append arguments to parent service arguments. + # externalauth.authmap declared optional because CAS may or may not be enabled. + arguments: + - '@entity_type.manager' + - '@entity_field.manager' + - '@?externalauth.authmap' diff --git a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php similarity index 85% rename from modules/custom/az_person/src/AZUserToolbarLinkBuilder.php rename to modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index 4fdbb0974e..359575a15f 100644 --- a/modules/custom/az_person/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -1,6 +1,6 @@ t('View user account'); - } - if (!empty($original_links['account_edit'])) { - $original_links['account_edit']['title'] = $this->t('Edit user account'); - } - // Add in our links among the user module links. - $links = array_merge($additional_links, $original_links); - $build['#links'] = $links; - } return $build; } diff --git a/modules/custom/az_person/az_person.services.yml b/modules/custom/az_person/az_person.services.yml deleted file mode 100644 index e3d603cf4e..0000000000 --- a/modules/custom/az_person/az_person.services.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - autowire: true - autoconfigure: true - # Decorates the normal user module links. - az_person.toolbar_link_builder: - class: Drupal\az_person\AZUserToolbarLinkBuilder - decorates: user.toolbar_link_builder - parent: user.toolbar_link_builder - # Append arguments to parent service arguments. - # externalauth.authmap declared optional because CAS may or may not be enabled. - arguments: - - '@entity_type.manager' - - '@entity_field.manager' - - '@?externalauth.authmap' From 0ea2a8824ff759af4c142f8347d721a9e9ceb3da Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 10:50:25 -0700 Subject: [PATCH 11/14] Add links back --- .../az_core/src/AZUserToolbarLinkBuilder.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index 06def7b15d..f02a9544b2 100644 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -107,7 +107,19 @@ public function renderToolbarLinks() { } } } - + // Transform some of the user module links for clarity. + if (!empty($build['#links'])) { + $original_links = $build['#links']; + if (!empty($original_links['account'])) { + $original_links['account']['title'] = $this->t('View user account'); + } + if (!empty($original_links['account_edit'])) { + $original_links['account_edit']['title'] = $this->t('Edit user account'); + } + // Add in our links among the user module links. + $links = array_merge($additional_links, $original_links); + $build['#links'] = $links; + } return $build; } From fc1d1daab09ac6be60b3d44d8f41798805d9184b Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 11:08:40 -0700 Subject: [PATCH 12/14] Update modules/custom/az_core/az_core.services.yml Co-authored-by: Joe Parsons <471936+joeparsons@users.noreply.github.com> --- modules/custom/az_core/az_core.services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/az_core/az_core.services.yml b/modules/custom/az_core/az_core.services.yml index 1e7e2f1a5d..0331325d53 100755 --- a/modules/custom/az_core/az_core.services.yml +++ b/modules/custom/az_core/az_core.services.yml @@ -25,7 +25,7 @@ services: - '@config_update.config_list' - '@module_handler' # Decorates the normal user module links. - az_person.toolbar_link_builder: + az_core.toolbar_link_builder: class: Drupal\az_core\AZUserToolbarLinkBuilder decorates: user.toolbar_link_builder parent: user.toolbar_link_builder From 5e6dcaab898456a2775a6eafca93489672c689fe Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 11:09:19 -0700 Subject: [PATCH 13/14] Update modules/custom/az_core/src/AZUserToolbarLinkBuilder.php --- modules/custom/az_core/src/AZUserToolbarLinkBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index f02a9544b2..0e48b9cc24 100644 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -15,7 +15,7 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { /** - * Authmap service definition. + * Drupal\externalauth\AuthmapInterface definition. * * @var \Drupal\externalauth\AuthmapInterface */ From b96c58552621b728f48d63e7b66fd3c3927aa5bd Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Dec 2024 11:09:55 -0700 Subject: [PATCH 14/14] Update modules/custom/az_core/src/AZUserToolbarLinkBuilder.php --- modules/custom/az_core/src/AZUserToolbarLinkBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php index 0e48b9cc24..17e49d7a9d 100644 --- a/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php +++ b/modules/custom/az_core/src/AZUserToolbarLinkBuilder.php @@ -22,7 +22,7 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder { protected $authmap; /** - * Entity type manager service definition. + * Drupal\Core\Entity\EntityTypeManagerInterface definition. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */