<?php

namespace KupShop\DeliveryPriceListBundle\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('settingsMenu/delivery',
            [
                'name' => 'delivery_pricelists',
                'left' => 's=menu.php&type=deliveryPriceLists', 'right' => 's=list.php&type=deliveryPriceLists',
            ]
        );

        $event->addRights('delivery_pricelists',
            [
                'modules' => [
                    'delivery_pricelist',
                ],
                'rights' => [
                    'DELVR',
                ],
            ]
        );
    }
}
