|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\ThemeBundle\Controller\Dashboard; |
|
15
|
|
|
|
|
16
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; |
|
17
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
19
|
|
|
use Symfony\Component\Routing\Attribute\Route; |
|
20
|
|
|
use Zikula\CoreBundle\Bundle\MetaData\MetaDataAwareBundleInterface; |
|
21
|
|
|
use Zikula\ThemeBundle\ExtensionMenu\ExtensionMenuInterface; |
|
22
|
|
|
use function Symfony\Component\Translation\t; |
|
23
|
|
|
|
|
24
|
|
|
class UserDashboardController extends AbstractThemedDashboardController |
|
25
|
|
|
{ |
|
26
|
|
|
protected function getName(): string |
|
27
|
|
|
{ |
|
28
|
|
|
return 'user'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function configureDashboard(): Dashboard |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->getDashboardWithBranding(true); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function configureMenuItems(): iterable |
|
37
|
|
|
{ |
|
38
|
|
|
yield MenuItem::linkToDashboard(t('Home'), 'fas fa-home'); |
|
39
|
|
|
yield MenuItem::linkToUrl(t('Administration'), 'fas fa-wrench', '/admin')->setPermission('ROLE_ADMIN'); |
|
40
|
|
|
|
|
41
|
|
|
yield MenuItem::section(); |
|
42
|
|
|
$menuItemsByBundle = $this->extensionMenuCollector->getAllByContext(ExtensionMenuInterface::CONTEXT_USER); |
|
43
|
|
|
foreach ($menuItemsByBundle as $bundleName => $extensionMenuItems) { |
|
44
|
|
|
$bundle = $this->kernel->getBundle($bundleName); |
|
45
|
|
|
if (!($bundle instanceof MetaDataAwareBundleInterface)) { |
|
46
|
|
|
continue; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$menuItems = is_array($extensionMenuItems) ? $extensionMenuItems : iterator_to_array($extensionMenuItems); |
|
50
|
|
|
if (!count($menuItems)) { |
|
51
|
|
|
continue; |
|
52
|
|
|
} |
|
53
|
|
|
$bundleInfo = $bundle->getMetaData(); |
|
54
|
|
|
yield MenuItem::subMenu($bundleInfo->getDisplayName(), $bundleInfo->getIcon())->setSubItems($menuItems); |
|
55
|
|
|
/*foreach ($menuItems as $item) { |
|
56
|
|
|
yield $item; |
|
57
|
|
|
}*/ |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
#[Route('/', name: 'user_home')] |
|
62
|
|
|
public function home(): Response |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->redirectToRoute('user_dashboard', ['_locale' => $this->defaultLocale]); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
#[Route('/{_locale}', name: 'user_dashboard')] |
|
68
|
|
|
public function index(): Response |
|
69
|
|
|
{ |
|
70
|
|
|
return parent::index(); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|