Skip to content

Commit

Permalink
EZP-32038: Move System information tab to ez-support-tools (#63)
Browse files Browse the repository at this point in the history
* EZP-32038: Move System information tab to ez-support-tools

* reverted not-mandatory composer dependency
  • Loading branch information
konradoboza authored Oct 17, 2020
1 parent 63af732 commit 022d6bb
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/lib/EventListener/ConfigureMainMenuListener.php
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'),
];
}
}

0 comments on commit 022d6bb

Please # to comment.