Fixes in routes for load from vendor directory for use composer for distribute modules

This commit is contained in:
absurdo 2023-10-25 21:20:21 +02:00
parent a6a95e0027
commit b619b4bb03

View file

@ -7,7 +7,7 @@ class Config {
static public $home_module='welcome';
static public $modules_allowed=['welcome'];
static public $modules_allowed=['welcome' => 'modules/welcome'];
static public $base_url='';
@ -17,6 +17,7 @@ class Config {
* Url: http://domain.com/
* Url: http://domain.com/index.php/{module}
* Url: http://domain.com/index.php/{module}/app/{arg1}/{arg2} -> modules/module/controller_app.php controller($args);
* Url: http://domain.com/index.php/{module}/index/{arg1}/{arg2} -> modules/module/controller_index.php AppController->App($args);
*/
function get_controller($controller, $args=[]) {
@ -65,7 +66,7 @@ function get_route($path_info) {
case 0:
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
$controller=\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
return \PhangoApp\PhaRouter\get_controller($controller, []);
@ -73,9 +74,11 @@ function get_route($path_info) {
case 1:
$controller='modules/'.$arr_path[1].'/controllers/app.php';
if(isset(Config::$modules_allowed[$arr_path[1]])) {
if(in_array($arr_path[1], Config::$modules_allowed)) {
$module_path=Config::$modules_allowed[$arr_path[1]];
$controller=$module_path.'/controllers/app.php';
return \PhangoApp\PhaRouter\get_controller($controller, []);
@ -85,9 +88,11 @@ function get_route($path_info) {
case 2:
$controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php';
if(isset(Config::$modules_allowed[$arr_path[1]])) {
if(in_array($arr_path[1], Config::$modules_allowed)) {
$module_path=Config::$modules_allowed[$arr_path[1]];
$controller=$module_path.'/controllers/'.$arr_path[2].'.php';
return \PhangoApp\PhaRouter\get_controller($controller, []);
@ -97,9 +102,11 @@ function get_route($path_info) {
default:
$controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php';
if(isset(Config::$modules_allowed[$arr_path[1]])) {
if(in_array($arr_path[1], Config::$modules_allowed)) {
$module_path=Config::$modules_allowed[$arr_path[1]];
$controller=$module_path.'/controllers/'.$arr_path[2].'.php';
$args=array_slice($arr_path, 2, count($arr_path));
@ -114,7 +121,7 @@ function get_route($path_info) {
}
else {
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
$controller=\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
return \PhangoApp\PhaRouter\get_controller($controller, []);