From aed63829d07a87387449ad420da103c4148dcd42 Mon Sep 17 00:00:00 2001 From: Emmanuel ROY Date: Thu, 22 Apr 2021 10:44:29 +0200 Subject: [PATCH] update : - fix url root directory return - adding arguments to command bin.php --- application/class/Url.php | 9 +++++++-- console/bin.php | 19 ++++++++++++++----- console/command/{app => App}/Log.php | 0 console/command/{sand => Sand}/Action.php | 0 console/command/{sand => Sand}/Cache.php | 0 console/command/{sand => Sand}/Conduit.php | 0 console/command/{sand => Sand}/Module.php | 0 console/command/{sand => Sand}/Page.php | 0 console/command/{sand => Sand}/Symfony.php | 0 9 files changed, 21 insertions(+), 7 deletions(-) rename console/command/{app => App}/Log.php (100%) rename console/command/{sand => Sand}/Action.php (100%) rename console/command/{sand => Sand}/Cache.php (100%) rename console/command/{sand => Sand}/Conduit.php (100%) rename console/command/{sand => Sand}/Module.php (100%) rename console/command/{sand => Sand}/Page.php (100%) rename console/command/{sand => Sand}/Symfony.php (100%) diff --git a/application/class/Url.php b/application/class/Url.php index d196156..8f66ea7 100644 --- a/application/class/Url.php +++ b/application/class/Url.php @@ -236,13 +236,18 @@ class Url } else { $scheme = 'http'; } - $base_url = $scheme . "://" . $url . "/"; + $base_url = $scheme . "://" . $url ; $url = $base_url; }else{ $url = PATH_URL; } - return $url . BASE_SERVER_DIRECTORY; + if(str_ends_with($url . "/" . BASE_SERVER_DIRECTORY , '/')){ + return substr($url . "/" . BASE_SERVER_DIRECTORY,0,-1); + }else { + return $url . "/" . BASE_SERVER_DIRECTORY; + } } + /** * Obtiens le fragment depuis une variable serveur, * ce qui est selon moi possible avec une bonne configuration serveur diff --git a/console/bin.php b/console/bin.php index d7589f1..3a7cd66 100644 --- a/console/bin.php +++ b/console/bin.php @@ -11,30 +11,39 @@ require dirname(__DIR__) . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR if (isset($argv[1])) { $option = explode(':', $argv[1]); $command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . ucfirst($option[0]) . ".php"; + + //récupération des arguments de la commande pour passage en paramètre de la méthode + $arguments = array(); + if (isset($argv[2])) { + for ($i = 2; $i < count($argv); $i++) { + $arguments[] = $argv[$i]; + } + } + if (is_file($command_file)) { $class = "\MVC\Command\\" . ucfirst($option[0]); $static_method = $option[1]; - $errors = $class::$static_method(); + $errors = $class::$static_method(...$arguments); if ($errors !== null) { \MVC\Classe\Logger::logCommandErrors($errors); } } else { - $command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "app" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php"; + $command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "App" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php"; if (is_file($command_file)) { $class = "\MVC\Command\\App\\" . ucfirst($option[0]); $static_method = $option[1]; - $errors = $class::$static_method(); + $errors = $class::$static_method(...$arguments); if ($errors !== null) { \MVC\Classe\Logger::logCommandErrors($errors); } }else { - $command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "sand" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php"; + $command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "Sand" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php"; if (is_file($command_file)) { $class = "\MVC\Command\\Sand\\" . ucfirst($option[0]); $static_method = $option[1]; - $errors = $class::$static_method(); + $errors = $class::$static_method(...$arguments); if ($errors !== null) { \MVC\Classe\Logger::logCommandErrors($errors); diff --git a/console/command/app/Log.php b/console/command/App/Log.php similarity index 100% rename from console/command/app/Log.php rename to console/command/App/Log.php diff --git a/console/command/sand/Action.php b/console/command/Sand/Action.php similarity index 100% rename from console/command/sand/Action.php rename to console/command/Sand/Action.php diff --git a/console/command/sand/Cache.php b/console/command/Sand/Cache.php similarity index 100% rename from console/command/sand/Cache.php rename to console/command/Sand/Cache.php diff --git a/console/command/sand/Conduit.php b/console/command/Sand/Conduit.php similarity index 100% rename from console/command/sand/Conduit.php rename to console/command/Sand/Conduit.php diff --git a/console/command/sand/Module.php b/console/command/Sand/Module.php similarity index 100% rename from console/command/sand/Module.php rename to console/command/Sand/Module.php diff --git a/console/command/sand/Page.php b/console/command/Sand/Page.php similarity index 100% rename from console/command/sand/Page.php rename to console/command/Sand/Page.php diff --git a/console/command/sand/Symfony.php b/console/command/Sand/Symfony.php similarity index 100% rename from console/command/sand/Symfony.php rename to console/command/Sand/Symfony.php