<?php
namespace Modules\Catalogue;

use Helpers\Parametres\Parametres;
use Modules\Catalogue\Controller\CatalogueExterneController;
use Modules\Catalogue\Controller\FormatController;
use Modules\Catalogue\Controller\ParametrageFormatController;
use Skeleton\Router;
use Skeleton\Module;
use Skeleton\Renderer\RendererInterface;
use Psr\Container\ContainerInterface;

class CatalogueModule extends Module
{
    const DEFINITIONS = __DIR__ . '/config.php';

    public function __construct(ContainerInterface $container)
    {
        $container->get(RendererInterface::class)->addPath('catalogue', __DIR__ . '/views');

        $router = $container->get(Router::class);

        $parametres     = new Parametres();
        $global         = '[A-Za-z0-9%._ @-]';

        $base_url = $container->get('baseUrl') . $container->get('Catalogue.prefix');

        //FORMAT
        $router->get($base_url. '/format', FormatController::class, 'Catalogue.Format.listeFormat');
        $router->get($base_url. '/format/delete/{IdFormat:'.$global.'+}', FormatController::class, 'Catalogue.Format.delete');
        $router->get($base_url. '/ajax/connecteur', FormatController::class, 'Catalogue.Format.ajaxConnecteur');
        $router->get($base_url. '/format/creatEdit[/{IdFormat:'.$global.'+}]', FormatController::class, 'Catalogue.Format.creatEdit');
        $router->get($base_url. '/format/validate[/{IdFormat:'.$global.'+}]', FormatController::class, 'Catalogue.Format.validate');

        //FORMAT PARAMETRAGE
        $router->get($base_url. '/format/parametrage/updateValue/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.updateValue');
        //mappage
        $router->get($base_url. '/format/parametrage/Mappage/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramMappage');
        $router->get($base_url. '/format/parametrage/resetMapping/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.resetMapping');

        //_multiMappage
        $router->get($base_url. '/format/parametrage/popup/multiMapp/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupMultiMapp');
        $router->get($base_url. '/format/parametrage/ajax/ajoutLigne/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigne');
        $router->get($base_url. '/format/parametrage/validateMultiMapping/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateMultiMapping');
        $router->get($base_url. '/format/popupMapping/{typeFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupMapping');

        //controle
        $router->get($base_url. '/format/parametrage/Controle/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramControle');

        //transco
        $router->get($base_url. '/format/parametrage/Transcodification/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramTransco');
        $router->get($base_url. '/format/parametrage/gestionTransco/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.gestionTransco');
        $router->get($base_url. '/format/parametrage/gestionTransco/validateTransco/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateTransco');
        $router->get($base_url. '/format/parametrage/ajax/transco/ajoutLigne', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigneTransco');
        $router->get($base_url. '/format/parametrage/popup/importTransco', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupImportTransco');
        $router->get($base_url. '/format/parametrage/ajax/importTransco', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxImportTransco');
        
        //Validation
        $router->get($base_url. '/format/parametrage/Validation/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramValidation');
        $router->get($base_url. '/format/parametrage/popup/validation/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupValidation');
        $router->get($base_url. '/format/parametrage/ajax/validation/ajoutLigne', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigneValidation');
        $router->get($base_url. '/format/parametrage/validateValidation/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateValidation');
    
    
        //CATALOGUE EXTERNE
        $router->get($base_url. '/catalogueExterne', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.listeCatalogue');
    }
}
