*/ // Déclaration du namespace namespace LaswitchTech\Core; // Import de classes supplémentaires dans l’espace de noms global use LaswitchTech\Core\Config; use LaswitchTech\Core\Strap; use Exception; class Bootstrap { const Default = [ "LOG" => [ "class" => "\LaswitchTech\Core\Log", "scope" => [ "Router", "API", "CLI" ] ], "REQUEST" => [ "class" => "\LaswitchTech\Core\Request", "scope" => [ "Router", "API", "CLI" ] ], "OUTPUT" => [ "class" => "\LaswitchTech\Core\Output", "scope" => [ "Router", "API", "CLI" ] ], "NET" => [ "class" => "\LaswitchTech\coreNet\Net", "scope" => [ "Router", "API", "CLI" ] ], "HELPER" => [ "class" => "\LaswitchTech\Core\Helpers", "scope" => [ "Router", "API", "CLI" ] ], "DATABASE" => [ "class" => "\LaswitchTech\coreDatabase\Database", "scope" => [ "Router", "API", "CLI" ] ], "MODEL" => [ "class" => "\LaswitchTech\Core\Models", "scope" => [ "Router", "API", "CLI" ] ], "LOCALE" => [ "class" => "\LaswitchTech\coreLocale\Locale", "scope" => [ "Router", "API", "CLI" ] ], "ENCRYPTION" => [ "class" => "\LaswitchTech\coreEncryption\Encryption", "scope" => [] ], "CSRF" => [ "class" => "\LaswitchTech\coreCSRF\CSRF", "scope" => [ "Router", "API" ] ], "SLS" => [ "class" => "\LaswitchTech\coreSLS\SLS", "scope" => [ "Router", "API", "CLI" ] ], "SMS" => [ "class" => "\LaswitchTech\coreSMS\SMS", "scope" => [ "Router", "API", "CLI" ] ], "SMTP" => [ "class" => "\LaswitchTech\coreSMTP\SMTP", "scope" => [ "Router", "API", "CLI" ] ], "IMAP" => [ "class" => "\LaswitchTech\coreIMAP\IMAP", "scope" => [ "Router", "API", "CLI" ] ], "INSTALLER" => [ "class" => "\LaswitchTech\coreInstaller\Installer", "scope" => [ "Router", "API", "CLI" ] ], "AUTH" => [ "class" => "\LaswitchTech\coreAuth\Auth", "scope" => [ "Router", "API" ] ], "ROUTER" => [ "class" => "\LaswitchTech\coreRouter\Router", "scope" => [ "Router" ] ], "API" => [ "class" => "\LaswitchTech\coreAPI\API", "scope" => [ "API" ] ], "CLI" => [ "class" => "\LaswitchTech\Core\CLI", "scope" => [ "CLI" ] ] ]; /** * Constructeur */ public function __construct($scope){ // Définir la variable globale global $CONFIG; // Initialiser Config $CONFIG = new Config(['bootstrap']); // Récupérer les « straps » $straps = $CONFIG->get('bootstrap'); // Boucler à travers les straps foreach(self::Default as $strap => $config){ // Vérifier s’il existe un strap alternatif if(isset($straps[$strap])){ // Boucler à travers le strap alternatif foreach($config as $key => $value){ // Vérifier si le strap alternatif a la clé if(isset($straps[$strap][$key])){ // Définir le strap alternatif $config[$key] = $straps[$strap][$key]; } } } // Vérifier si le strap ne fait pas partie du scope if(!in_array($scope,$config['scope'])) continue; // Initialiser la variable globale global ${$strap}; // Définir la classe $class = $config['class']; // Vérifier si la classe existe if(class_exists($class)){ // Initialiser la classe dans l’espace de noms global ${$strap} = new $class(); } else { // Définir la valeur par défaut comme null ${$strap} = new Strap(); } } } }