<?php

namespace KupShop\AdminBundle\EventListener;

use KupShop\KupShopBundle\Event\CreateMenuEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class CreateMenuListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            CreateMenuEvent::COMPLETING_TREE => [
                ['addItem', 200],
            ],
        ];
    }

    /**
     * @var CreateMenuEvent
     */
    public function addItem(CreateMenuEvent $event)
    {
        $event->addItem(
            'toolsMenu',
            [
                'name' => 'report_activities',
                'left' => 's=menu.php&type=reportActivities',
                'right' => 's=list.php&type=reportActivities',
            ]
        );
        $event->addRights(
            'report_activities',
            [
                'rights' => ['ACTIVITY_LOG_'],
            ]
        );

        $event->addItem(
            'toolsMenu',
            [
                'name' => 'gdpr',
                'left' => 'blank',
                'right' => 's=board.php&type=gdpr',
            ]
        );
        $event->addRights(
            'gdpr',
            [
                'rights' => ['OTH_SET_'],
            ]
        );
    }
}
