<?php

namespace KupShop\OrderDiscountBundle\AdminRegister;

use KupShop\AdminBundle\AdminRegister\AdminRegister;
use KupShop\AdminBundle\AdminRegister\IAdminRegisterDynamic;
use KupShop\AdminBundle\AdminRegister\IAdminRegisterStatic;

class OrderDiscountAdminRegister extends AdminRegister implements IAdminRegisterDynamic, IAdminRegisterStatic
{
    public function getDynamicMenu(): array
    {
        $menu[] =
            static::createMenuItem(
                'ordersMenu',
                [
                    'name' => 'OrderDiscounts',
                    'title' => translate('menu', 'OrderDiscounts'),
                    'left' => 's=menu.php&type=OrderDiscounts',
                    'right' => 's=list.php&type=OrderDiscounts',
                    'position' => 3,
                ]);
        $menu[] =
            static::createMenuItem('ordersMenu',
                [
                    'name' => 'OrderDiscountsCoupons',
                    'title' => translate('menu', 'OrderDiscountsCoupons'),
                    'left' => 's=menu.php&type=OrderDiscountsCoupons',
                    'right' => 's=list.php&type=OrderDiscountsCoupons',
                    'position' => 4,
                ]);

        if (findModule(\Modules::TRANSLATIONS)) {
            $menu[] = self::createMenuItem('translate',
                [
                    'name' => 'translate.translateOrderDiscounts',
                    'right' => 's=list.php&type=translateOrderDiscounts',
                    'position' => 5,
                ]);
        }

        return $menu;
    }

    public static function getPermissions(): array
    {
        return [
            static::createPermissions('OrderDiscounts', [\Modules::ORDERS], ['DISCNT']),
            static::createPermissions('OrderDiscountsCoupons', [\Modules::ORDERS], ['GENERATED_CODES']),
        ];
    }
}
