getmodules gestion des erreurs

This commit is contained in:
Fred Tempez 2021-02-11 10:31:58 +01:00
parent 8dff1cd069
commit fed10aa71d
2 changed files with 27 additions and 22 deletions

View File

@ -134,31 +134,36 @@ class helper {
* du nom réel * du nom réel
* du numéro de version * du numéro de version
*/ */
public static function getModules() { public static function getModules($folder = 'module') {
$dirs = array_diff(scandir('module'), array('..', '.'));
$dirs = array_diff(scandir($folder), array('..', '.'));
foreach ($dirs as $key => $value) { foreach ($dirs as $key => $value) {
// Dossier non vide // Dossier non vide
if (file_exists('module/' . $value . '/' . $value . '.php')) { if (file_exists($folder . '/' . $value . '/' . $value . '.php')) {
// Lire les constantes // Lire les constantes
$class_reflex = new \ReflectionClass($value); try {
$class_constants = $class_reflex->getConstants(); $class_reflex = new \ReflectionClass($value);
// Constante REALNAME $class_constants = $class_reflex->getConstants();
if (array_key_exists('REALNAME', $class_constants)) { // Constante REALNAME
$realName = $value::REALNAME; if (array_key_exists('REALNAME', $class_constants)) {
} else { $realName = $value::REALNAME;
$realName = ucfirst($value); } else {
} $realName = ucfirst($value);
// Constante VERSION }
if (array_key_exists('VERSION', $class_constants)) { // Constante VERSION
$version = $value::VERSION; if (array_key_exists('VERSION', $class_constants)) {
} else { $version = $value::VERSION;
$version = '0.0'; } else {
} $version = '0.0';
// Affection }
$modules [$value] = [ // Affection
'realName' => $realName, $modules [$value] = [
'version' => $version 'realName' => $realName,
]; 'version' => $version
];
} catch (Exception $e){
// on ne fait rien
}
} }
} }
return($modules); return($modules);

0
module/gps/gps.php Normal file
View File