diff --git a/core/c/autoloader.php b/core/c/autoloader.php index b9266aa..a01acfc 100644 --- a/core/c/autoloader.php +++ b/core/c/autoloader.php @@ -72,6 +72,8 @@ class Autoloader { (bool) $skip = false; (array) $normal = array(); + (array) $first = array(); + (array) $sorted = array(); if($section == self::SETTINGS_CLASS_POS) { $moduleSortOrder = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_CLASS_POS]; @@ -109,7 +111,7 @@ class Autoloader $skip = false; } } - if(array_key_exists(0, $first)) + if(is_array($first) && array_key_exists(0, $first)) { $sorted = array(); foreach($moduleSortOrder as $item) @@ -170,13 +172,20 @@ class Autoloader * @param string $moduleName * @return \RecursiveIteratorIterator */ - private static function folderContent( string $folderPath, string $moduleName = '' ): \RecursiveIteratorIterator + private static function folderContent( string $folderPath, string $moduleName = '' ): ?\RecursiveIteratorIterator { if(strstr($folderPath, self::REGEX_PATH_NAME) && $moduleName!="") { $folderPath = str_replace(self::REGEX_PATH_NAME, $moduleName, $folderPath); } - return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $folderPath )); + if(is_dir($folderPath)) + { + return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $folderPath )); + } + else + { + return null; + } } /** @@ -223,14 +232,17 @@ class Autoloader foreach($moduleInterfaceNames as $interfaceName) { $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::INTERFACE_FOLDER], $interfaceName); - foreach ($iterator as $item) + if(sizeof($iterator)>0) { - if($item->getFileName() != self::MY_FILE_NAME && $item->getFileName() != "." && $item->getFileName() != ".." && strstr($item->getFileName(), self::PHP_FILE_EXTENSION)) + foreach ($iterator as $item) { - $interfaces[] = array( - 'nfilename' => str_replace('.php', '', $item->getFileName()), - 'filepathname' => $item->getPath() . '/' . $item->getFileName() - ); + if($item->getFileName() != self::MY_FILE_NAME && $item->getFileName() != "." && $item->getFileName() != ".." && strstr($item->getFileName(), self::PHP_FILE_EXTENSION)) + { + $interfaces[] = array( + 'nfilename' => str_replace('.php', '', $item->getFileName()), + 'filepathname' => $item->getPath() . '/' . $item->getFileName() + ); + } } } if(is_array($interfaces)) @@ -302,7 +314,7 @@ class Autoloader } $modulesPluginsNames = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_CLASS_POS]; $pluginNames = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_CLASS_PLUGIN_POS]; - + $plugins = []; foreach($modulesPluginsNames as $pluginsName) { $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::PLUGINS_FOLDER], $pluginsName ); diff --git a/core/c/dispatcher.php b/core/c/dispatcher.php index ec77c19..d2ee789 100644 --- a/core/c/dispatcher.php +++ b/core/c/dispatcher.php @@ -39,23 +39,26 @@ final class Dispatcher Router::getInstance(); Router::getInstance()->route(); Autoloader::getInstance()->runRequireOnce(); - require_once __DIR__ . '/../../application/controller/' . Router::getInstance()->tplName() . 'Controller.php'; - $class = "Nibiru\\".\Nibiru\Router::getInstance()->tplName()."Controller"; - $controller = new $class(); - if(array_key_exists('_action', $_REQUEST)) + if(is_file(__DIR__ . '/../../application/controller/' . Router::getInstance()->tplName() . 'Controller.php')) { - $action = $_REQUEST['_action']."Action"; - $controller->navigationAction(); - $controller->$action(); - $controller->pageAction(); - } - else - { - $controller->navigationAction(); - $controller->pageAction(); - } + require_once __DIR__ . '/../../application/controller/' . Router::getInstance()->tplName() . 'Controller.php'; + $class = "Nibiru\\".\Nibiru\Router::getInstance()->tplName()."Controller"; + $controller = new $class(); + if(array_key_exists('_action', $_REQUEST)) + { + $action = $_REQUEST['_action']."Action"; + $controller->navigationAction(); + $controller->$action(); + $controller->pageAction(); + } + else + { + $controller->navigationAction(); + $controller->pageAction(); + } - Debug::getInstance(); - Display::getInstance()->display(); + Debug::getInstance(); + Display::getInstance()->display(); + } } } \ No newline at end of file diff --git a/core/c/registry.php b/core/c/registry.php index 2af7581..4aef933 100644 --- a/core/c/registry.php +++ b/core/c/registry.php @@ -70,11 +70,14 @@ final class Registry { $module = new \stdClass(); $module_settings = parse_ini_file($settings->getPathName(), true); - foreach ( $module_settings[strtoupper($this->getModuleName())] as $key=>$value) + if(array_key_exists(strtoupper($this->getModuleName()), $module_settings)) { - $module->$key = $value; + foreach ($module_settings[strtoupper($this->getModuleName())] as $key=>$value) + { + $module->$key = $value; + } + $this->_modules_config[$this->getModuleName()] = $module; } - $this->_modules_config[$this->getModuleName()] = $module; } } }