Skip to content

Commit

Permalink
[#3512157] Added better access check on local task links and better a…
Browse files Browse the repository at this point in the history
…rray element checks.
  • Loading branch information
richardgaunt committed Mar 11, 2025
1 parent 944cc2e commit 5603b9f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/themes/contrib/civictheme/includes/local_tasks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
declare(strict_types=1);

use Drupal\civictheme\CivicthemeConstants;
use Drupal\Core\Access\AccessResultInterface;

/**
* Pre-process for local tasks.
Expand All @@ -19,14 +20,14 @@ function _civictheme_preprocess_menu_local_tasks(array &$variables): void {
foreach ($local_task_types as $local_task_type) {
$variables['links'][$local_task_type] = [];
foreach ($variables[$local_task_type] as $link) {
if (!empty($link['#access']) && $link['#access']->isAllowed()) {
if (!empty($link['#access']) && ($link['#access'] === TRUE || ($link['#access'] instanceof AccessResultInterface && $link['#access']->isAllowed()))) {
$variables['links'][$local_task_type][] = [
'theme' => $context_theme,
'text' => $link['#link']['title'],
'url' => $link['#link']['url']->toString(),
'is_new_window' => FALSE,
'is_external' => $link['#link']['url']->isExternal(),
'modifier_class' => $link['#active'] ? 'ct-tabs__tab--selected selected' : '',
'modifier_class' => !empty($link['#active']) && $link['#active'] === TRUE ? 'ct-tabs__tab--selected selected' : '',
'weight' => $link['#weight'] ?? 0,
];
}
Expand Down

0 comments on commit 5603b9f

Please sign in to comment.