<?php

namespace KupShop\RestrictionsBundle\EventListener;

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

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

    /**
     * @var CreateMenuEvent
     */
    public function addItem(CreateMenuEvent $event)
    {
        $event->addItem('productsMenu',
            [
                'name' => 'restrictions',
                'left' => 's=menu.php&type=restrictions', 'right' => 's=list.php&type=restrictions',
            ]
        );

        $event->addRights('restrictions',
            [
                'modules' => [
                    'restrictions',
                ],
                'rights' => ['RESTRICTIONS'],
            ]
        );
    }
}
