Skip to content

Commit

Permalink
[fix] Fix menu filter issue for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed May 25, 2024
1 parent 8afdce2 commit 7272807
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/Domain/Menu/Repositories/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* menu class - Menu definitions
*/

namespace Leantime\Domain\Menu\Repositories {

use Leantime\Core\Environment as EnvironmentCore;
Expand Down Expand Up @@ -143,16 +144,12 @@ class Menu
public function __construct(
/** @var SettingRepository */
private SettingRepository $settingsRepo,

/** @var LanguageCore */
private LanguageCore $language,

/** @var EnvironmentCore */
private EnvironmentCore $config,

/** @var TicketService */
private TicketService $ticketsService,

/** @var AuthService */
private AuthService $authService,
) {
Expand Down Expand Up @@ -251,14 +248,21 @@ function: 'getMenuStructure'
public function getMenuStructure(string $menuType = ''): array
{
$language = $this->language;
$filter = "menuStructures.$menuType";

$menuCollection = collect($this->menuStructures)->map(
function ($menu) use ($menuType, $filter) {
return self::dispatch_filter(
$filter,
$this->buildMenuStructure($menu, $filter),
'getMenuStructure'
);
}
)->all();

$this->menuStructures = self::dispatch_filter(
'menuStructures',
collect($this->menuStructures)->map(fn ($menu, $menuType) => self::dispatch_filter(
hook: $filter = "menuStructures.$menuType",
payload: $this->buildMenuStructure($menu, $filter),
function: 'getMenuStructure'
))->all(),
$menuCollection,
['menuType' => $menuType]
);

Expand All @@ -275,8 +279,7 @@ function: 'getMenuStructure'
ksort($menuStructure);

foreach ($menuStructure as $key => $element) {

if(isset($menuStructure[$key]['title'])){
if (isset($menuStructure[$key]['title'])) {
$menuStructure[$key]['title'] = $language->__($element['title']);
}

Expand Down

0 comments on commit 7272807

Please sign in to comment.