Skip to content

Commit 732a1b6

Browse files
committed
Lock out components section if it is not configured properly
1 parent 78c0826 commit 732a1b6

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

bundle/Controller/Admin/Components/Index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function __construct(
4040
*/
4141
public function __invoke(Request $request): Response
4242
{
43+
if (!$this->configResolver->hasParameter('ibexa_component.parent_locations', 'netgen_layouts')) {
44+
throw $this->createNotFoundException();
45+
}
46+
4347
$filterForm = $this->createForm(ComponentFilterType::class);
4448
$filterForm->handleRequest($request);
4549

bundle/EventListener/Admin/MainMenuBuilderListener.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
88
use Ibexa\AdminUi\Menu\MainMenuBuilder;
9+
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
910
use Knp\Menu\ItemInterface;
1011
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1112
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@@ -19,6 +20,7 @@ final class MainMenuBuilderListener implements EventSubscriberInterface
1920
{
2021
public function __construct(
2122
private AuthorizationCheckerInterface $authorizationChecker,
23+
private ConfigResolverInterface $configResolver,
2224
) {}
2325

2426
public static function getSubscribedEvents(): array
@@ -75,10 +77,12 @@ private function addLayoutsSubMenu(ItemInterface $menu): void
7577
->setLabel('menu.main_menu.transfer')
7678
->setExtra('translation_domain', 'nglayouts_admin');
7779

78-
$layouts
79-
->addChild('components', ['route' => 'nglayouts_admin_ibexa_components_index'])
80-
->setLabel('menu.main_menu.ibexa.components')
81-
->setExtra('translation_domain', 'nglayouts_admin');
80+
if ($this->configResolver->hasParameter('ibexa_component.parent_locations', 'netgen_layouts')) {
81+
$layouts
82+
->addChild('components', ['route' => 'nglayouts_admin_ibexa_components_index'])
83+
->setLabel('menu.main_menu.ibexa.components')
84+
->setExtra('translation_domain', 'nglayouts_admin');
85+
}
8286

8387
$menu->reorderChildren($menuOrder);
8488
}

bundle/Resources/config/services/admin.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ services:
9090
class: Netgen\Bundle\LayoutsIbexaBundle\EventListener\Admin\MainMenuBuilderListener
9191
arguments:
9292
- "@security.authorization_checker"
93+
- "@ibexa.config.resolver"
9394
tags:
9495
- { name: kernel.event_subscriber }
9596

0 commit comments

Comments
 (0)