- added command to list users - corrected wrong german translation - work contract validations - prevent error with missing params - use collapsible, minor UI improvement - added classes to target menu buttons in custom rules - disable webpack notifier, incompatible with mac arm - use explicit menu service to generate menu - bump to fontawesome 6 and replace restart icon - change repeat icon for recent activities - moved user bookmarks (favorites) to top nav - fix totp seconds window (leeway) - new migration to fix remaining user preferences with dots in name - remove duplicate named column in user screen - unify and added translations - added missing filter and tags to InvoiceSecurity
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Twig\Runtime;
|
|
|
|
use App\Entity\User;
|
|
use App\Utils\MenuItemModel;
|
|
use App\Utils\MenuService;
|
|
use Twig\Extension\RuntimeExtensionInterface;
|
|
|
|
final class MenuExtension implements RuntimeExtensionInterface
|
|
{
|
|
public function __construct(private MenuService $menuService)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @return array<MenuItemModel>
|
|
*/
|
|
public function getUserShortcuts(User $user): array
|
|
{
|
|
$shortcuts = $user->getPreferenceValue('favorite_routes');
|
|
if (!\is_string($shortcuts) || trim($shortcuts) === '') {
|
|
return [];
|
|
}
|
|
|
|
$favMenu = [];
|
|
|
|
$shortcuts = explode(',', $shortcuts);
|
|
$menu = $this->menuService->getKimaiMenu();
|
|
foreach ($shortcuts as $fav) {
|
|
$tmp = $menu->findById($fav);
|
|
if ($tmp !== null && !$tmp->hasChildren()) {
|
|
$favMenu[] = clone $tmp;
|
|
}
|
|
}
|
|
|
|
return $favMenu;
|
|
}
|
|
}
|