-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-32038: Move System information tab to ez-support-tools (#63)
* EZP-32038: Move System information tab to ez-support-tools * reverted not-mandatory composer dependency
- Loading branch information
1 parent
63af732
commit 022d6bb
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzSupportTools\EventListener; | ||
|
||
use eZ\Publish\API\Repository\PermissionResolver; | ||
use EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent; | ||
use EzSystems\EzPlatformAdminUi\Menu\MainMenuBuilder; | ||
use EzSystems\EzPlatformAdminUi\Menu\MenuItemFactory; | ||
use JMS\TranslationBundle\Model\Message; | ||
use JMS\TranslationBundle\Translation\TranslationContainerInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class ConfigureMainMenuListener implements EventSubscriberInterface, TranslationContainerInterface | ||
{ | ||
public const ITEM_ADMIN__SYSTEMINFO = 'main__admin__systeminfo'; | ||
|
||
/** @var \EzSystems\EzPlatformAdminUi\Menu\MenuItemFactory */ | ||
private $menuItemFactory; | ||
|
||
/** @var \eZ\Publish\API\Repository\PermissionResolver */ | ||
private $permissionResolver; | ||
|
||
public function __construct( | ||
MenuItemFactory $menuItemFactory, | ||
PermissionResolver $permissionResolver | ||
) { | ||
$this->menuItemFactory = $menuItemFactory; | ||
$this->permissionResolver = $permissionResolver; | ||
} | ||
|
||
/** | ||
* @param \EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent $event | ||
*/ | ||
public function onMenuConfigure(ConfigureMenuEvent $event): void | ||
{ | ||
$menu = $event->getMenu(); | ||
|
||
if (!$this->permissionResolver->hasAccess('setup', 'system_info')) { | ||
return; | ||
} | ||
|
||
$menu->getChild(MainMenuBuilder::ITEM_ADMIN)->addChild( | ||
$this->menuItemFactory->createItem( | ||
self::ITEM_ADMIN__SYSTEMINFO, | ||
[ | ||
'route' => 'ezplatform.systeminfo', | ||
'extras' => [ | ||
'orderNumber' => 10, | ||
], | ||
], | ||
) | ||
); | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ConfigureMenuEvent::MAIN_MENU => 'onMenuConfigure', | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getTranslationMessages(): array | ||
{ | ||
return [ | ||
(new Message(self::ITEM_ADMIN__SYSTEMINFO, 'menu'))->setDesc('System Information'), | ||
]; | ||
} | ||
} |