getMessage() . "\n"); } // (EP 2021 09 Ajout nouveaux fichiers config pour les champs obligatoires (et les autorisations)) //$config_mandatory_fields_file_name = 'app_labinvent_mandatory_fields'; // Si le fichier de conf n'existe pas, on le crée en copiant le fichier par défaut //if ( !file_exists(CONFIG.DS.$config_mandatory_fields_file_name.'.yml') ) //$config_matos_full_file_name = $config_matos_full_file_name_default = CONFIG.DS.CONFIG_MATERIEL_FIELDS_FILE_NAME; $config_matos_full_file_name = $config_matos_full_file_name_default = CONFIG_MATERIEL_FIELDS_FILE_NAME; //$config_matos_full_file_name_default = $config_matos_full_file_name; $config_matos_full_file_name .= '.yml'; $config_matos_full_file_name_default .= '.default.yml'; //if ( !file_exists($config_matos_full_file_name) ) copy($config_matos_full_file_name_default, $config_matos_full_file_name); try { Configure::config('my_yaml_engine', new YamlConfig()); //Configure::load($config_mandatory_fields_file_name, 'yaml', true); Configure::load(CONFIG_MATERIEL_FIELDS_FILE_NAME, 'my_yaml_engine'); //Configure::load('app_labinvent_mandatory_fields_IP2I', 'yaml'); //Configure::load('app_labinvent_authorizations', 'yaml'); } catch (\Exception $e) { echo("
config/bootstrap.php: Impossible de charger le fichier de configuration des champs matériels (".CONFIG.DS.CONFIG_MATERIEL_FIELDS_FILE_NAME.".yml)"); echo("
- soit ce fichier n'est pas accessible en lecture par le serveur web (attention, il faut aussi qu'il soit accessible en écriture)"); echo("
- soit il n'existe pas => dans ce cas, créez le en faisant une copie du fichier de configuration par défaut :"); echo("
cd ".CONFIG); echo("
cp $config_matos_full_file_name_default $config_matos_full_file_name"); echo("
chown webserver_user_name $config_matos_full_file_name"); echo("
chmod 600 $config_matos_full_file_name"); echo("
(si vous ne voulez pas faire le chown, faite plutot un chmod 666, moins propre, mais marche aussi)"); die(); } // Load an environment local configuration file. // You can use a file like app_local.php to provide local overrides to your // shared configuration. //Configure::load('app_local', 'default'); // When debug = false the metadata cache should last // for a very very long time, as we don't want // to refresh the cache while users are doing requests. if (!Configure::read('debug')) { Configure::write('Cache._cake_model_.duration', '+1 years'); Configure::write('Cache._cake_core_.duration', '+1 years'); } /** * Set server timezone to UTC. You can change it to another timezone of your * choice but using UTC makes time calculations / conversions easier. */ //date_default_timezone_set('UTC'); // GMT+0 date_default_timezone_set('Europe/Paris'); /** * Configure the mbstring extension to use the correct encoding. */ mb_internal_encoding(Configure::read('App.encoding')); /** * Set the default locale. This controls how dates, number and currency is * formatted and sets the default language to use for translations. */ ini_set('intl.default_locale', Configure::read('App.defaultLocale')); /** * Register application error and exception handlers. */ $isCli = PHP_SAPI === 'cli'; if ($isCli) { (new ConsoleErrorHandler(Configure::read('Error')))->register(); } else { (new ErrorHandler(Configure::read('Error')))->register(); } // Include the CLI bootstrap overrides. if ($isCli) { require __DIR__ . '/bootstrap_cli.php'; } /** * Set the full base URL. * This URL is used as the base of all absolute links. * * If you define fullBaseUrl in your config file you can remove this. */ if (!Configure::read('App.fullBaseUrl')) { $s = null; if (env('HTTPS')) { $s = 's'; } $httpHost = env('HTTP_HOST'); if (isset($httpHost)) { Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); } unset($httpHost, $s); } //(EP) 16/1/19 for 3.7 //Cache::config(Configure::consume('Cache')); Cache::setConfig(Configure::consume('Cache')); //ConnectionManager::config(Configure::consume('Datasources')); ConnectionManager::setConfig(Configure::consume('Datasources')); //Email::configTransport(Configure::consume('EmailTransport')); //Email::setConfigTransport(Configure::consume('EmailTransport')); TransportFactory::setConfig(Configure::consume('EmailTransport')); //Email::config(Configure::consume('Email')); Email::setConfig(Configure::consume('Email')); //Log::config(Configure::consume('Log')); Log::setConfig(Configure::consume('Log')); //Security::salt(Configure::consume('Security.salt')); Security::setSalt(Configure::consume('Security.salt')); /** * The default crypto extension in 3.0 is OpenSSL. * If you are migrating from 2.x uncomment this code to * use a more compatible Mcrypt based implementation */ //Security::engine(new \Cake\Utility\Crypto\Mcrypt()); /** * Setup detectors for mobile and tablet. */ //(EP) //Request::addDetector('mobile', function ($request) { ServerRequest::addDetector('mobile', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isMobile(); }); //(EP) //Request::addDetector('tablet', function ($request) { ServerRequest::addDetector('tablet', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isTablet(); }); /** * Custom Inflector rules, can be set to correctly pluralize or singularize * table, model, controller names or whatever other string is passed to the * inflection functions. * * Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); * Inflector::rules('irregular', ['red' => 'redlings']); * Inflector::rules('uninflected', ['dontinflectme']); * Inflector::rules('transliteration', ['/å/' => 'aa']); */ // (EP) je sais pas trop comment faire ça... Inflector::rules('irregular', ['SurCategory' => 'Domaine']); Inflector::rules('irregular', ['SurCategories' => 'Domaines']); /** * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ /* (EP) * TODO: * Depuis cakephp3.7 les plugins sont à mettre dans src/Application.php * cf https://book.cakephp.org/3.0/en/migrations.html */ Plugin::load('Migrations'); /* (EP) * Pour générer du pdf (à la place de fpdf qui ne marche pas au CRAL) */ Plugin::load('Dompdf'); // DebugKit (cf https://book.cakephp.org/debugkit/3/fr/index.html) // Only try to load DebugKit in development mode // Debug Kit should not be installed on a production system if (Configure::read('debug')) { // Whitelister mes sites locaux : Configure::write('DebugKit.safeTld', ['localhost', 'dev', 'invalid', 'test', 'example', 'local', 'devv']); /* (EP 20200316 added pour éviter l'erreur suivante retrouvée dans logs/error.log : * 2020-03-16 12:20:28 Warning: DebugKit is disabling itself as your host `labinvent.devv` is not in the known safe list of top-level-domains * (localhost, invalid, test, example, local). If you would like to force DebugKit on * use the `DebugKit.forceEnable` Configure option. */ //Configure::write('DebugKit.forceEnable', true); // Autres options dispo : //Configure::write('DebugKit.ignoreAuthorization', true); //Configure::write('DebugKit.panels', ['DebugKit.Packages' => false]); // Maintenant on peut charger DebugKit normalement //Plugin::load('DebugKit', ['bootstrap' => true]); Plugin::load('DebugKit', ['bootstrap' => true, 'routes' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. * * Also enable immutable time objects in the ORM. */ Type::build('time') ->useImmutable() ->useLocaleParser(); Type::build('date') ->useImmutable() ->useLocaleParser(); Type::build('datetime') ->useImmutable() ->useLocaleParser(); /* * Bootstrap-ui (EP added 28/1/2020) * https://github.com/FriendsOfCake/bootstrap-ui/tree/develop */ //Cake\Core\Plugin::load('BootstrapUI'); //Plugin::load('BootstrapUI'); Plugin::load('BootstrapUI', ['autoload' => true]); // Activer Stats via src/Routing/Filter/SessionTimeoutFilter.php $SessionTimeoutON = false; //$SessionTimeoutON = true; // (EP20201022) Pour gérer le timeout auto if ($SessionTimeoutON) DispatcherFactory::add('SessionTimeout');