Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3946 Whitescreen if az_person not installed. #3947

Merged
merged 16 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/custom/az_core/az_core.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ services:
arguments:
- '@entity_type.manager'
- '@?externalauth.authmap'
- '@module_handler'
17 changes: 15 additions & 2 deletions modules/custom/az_core/src/AZUserToolbarLinkBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\az_core;

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
joeparsons marked this conversation as resolved.
Show resolved Hide resolved
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Url;
use Drupal\externalauth\AuthmapInterface;
Expand All @@ -27,6 +28,13 @@ class AZUserToolbarLinkBuilder extends ToolbarLinkBuilder {
*/
protected $entityTypeManager;

/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;

/**
* ToolbarHandler constructor.
*
Expand All @@ -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.
joeparsons marked this conversation as resolved.
Show resolved Hide resolved
*/
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;
}

/**
Expand All @@ -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');
Expand Down
Loading