Max F 5 lat temu
rodzic
commit
4efe3e5657
3 zmienionych plików z 25 dodań i 2 usunięć
  1. 1 1
      src/Lib/Email/Email_lib.php
  2. 14 0
      src/Routing/Route.php
  3. 10 1
      src/Routing/Router.php

+ 1 - 1
src/Lib/Email/Email_lib.php

@@ -27,7 +27,7 @@ class Email_lib
 			return boolval($smtp_hook_func); // permet de mettre "1" pour un retour ok ou "0" pour un retour en erreur
 		}
 
-		if (true) {
+		if (false) {
 			$mail = [
 				'from' => $from,
 				'from_name' => $from_name,

+ 14 - 0
src/Routing/Route.php

@@ -7,6 +7,8 @@ class Route
 {
 	private $name = null;
 	private $methods = [];
+	private $called_method = null;
+	private $called_url = null;
 	private $match_url = '';
 	private $match_type = 'exact';
 	private $regex_params = [];
@@ -35,6 +37,18 @@ class Route
 		$this->match_url = $match_url;
 	}
 
+	// Set route called method
+	public function setCalledMethod($called_method)
+	{
+		$this->called_method = $called_method;
+	}
+
+	// Set route called url
+	public function setCalledUrl($called_url)
+	{
+		$this->called_url = $called_url;
+	}
+
 	// Get route match url
 	public function getMatchUrl()
 	{

+ 10 - 1
src/Routing/Router.php

@@ -71,6 +71,9 @@ class Router
 				pre($route);
 			}
 
+			$route->setCalledMethod($request_method);
+			$route->setCalledUrl($request_uri);
+
 			$match_params = $route->match($request_method, $request_uri);
 
 			if (! is_null($match_params)) {
@@ -108,13 +111,19 @@ class Router
 	public static function routeRun($route, $callback, $request_method, $request_uri, $match_params)
 	{
 		if (gettype($callback) == 'array') {
+			//echo " => ARRAY !<br />" . PHP_EOL;
+			//pre($callback, 1);
 			$class = new $callback[0]($route, $request_method, $request_uri);
 			call_user_func([$class, $callback[1]], $match_params);
 
 		} else {
-			$callback($route, $request_method, $request_uri);
+			//echo " => FUNCTION !<br />" . PHP_EOL;
+			//pre($callback, 1);
+			//$callback($route, $request_method, $request_uri);
+			$callback($route, $match_params);
 		}
 
+
 		return true;
 	}