Skip to content

Commit c2761ce

Browse files
ff1601comserver1601com
authored andcommitted
fix issue with hook visibility for non-admins
1 parent 946a5db commit c2761ce

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/EventListener/GetUserNavigationListener.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717
*/
1818
class GetUserNavigationListener
1919
{
20-
20+
/**
21+
* @var RouterInterface
22+
*/
2123
private $_routerInterface;
2224

25+
/**
26+
* GetUserNavigationListener constructor.
27+
* @param RouterInterface $_routerInterface
28+
*/
2329
public function __construct(RouterInterface $_routerInterface)
2430
{
2531
$this->_routerInterface = $_routerInterface;
@@ -32,12 +38,16 @@ public function __construct(RouterInterface $_routerInterface)
3238
*/
3339
public function __invoke(array $modules, bool $showAll): array
3440
{
35-
$modules['agentur1601com']['modules']['core'] = [
36-
'label' => 'Unterstützen',
37-
'title' => 'The core bundle',
38-
'class' => 'agentur1601com',
39-
'href' => $this->_routerInterface->generate('agentur1601com_core_backend'),
40-
];
41+
$user = \Contao\BackendUser::getInstance();
42+
43+
if ($user->hasAccess(['core'], 'modules')) {
44+
$modules['agentur1601com']['modules']['core'] = [
45+
'label' => 'Unterstützen',
46+
'title' => 'The core bundle',
47+
'class' => 'agentur1601com',
48+
'href' => $this->_routerInterface->generate('agentur1601com_core_backend'),
49+
];
50+
}
4151

4252
return $modules;
4353
}

src/Resources/contao/config/config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
// Hook for backend menu entry
1515
$GLOBALS['TL_HOOKS']['getUserNavigation'][] = ['Agentur1601com\\CoreBundle\\EventListener\\GetUserNavigationListener', '__invoke'];
1616

17+
1718
// Load backend style sheet
1819
if (TL_MODE == "BE") {
1920
$GLOBALS['TL_CSS'][] = '/bundles/agentur1601comcore/css/be_core_style.css';
20-
}
21+
}

0 commit comments

Comments
 (0)