Explorar el Código

Merge branch 'master' of ssh://gogs.vipe.re:6022/KarmaSolutions/KarmaFW

Max F hace 5 años
padre
commit
b07905e1bf
Se han modificado 2 ficheros con 48 adiciones y 0 borrados
  1. 41 0
      src/App.php
  2. 7 0
      src/WebApp.php

+ 41 - 0
src/App.php

@@ -155,4 +155,45 @@ class App
 	}
 	*/
 
+
+	public static function routeCommand($argv)
+	{
+		if (! self::$booted) {
+			self::boot();
+		}
+
+		$arguments = array_slice($argv, 0);
+		$script_name = array_shift($arguments);
+		$command_name = array_shift($arguments);
+		$class_name = implode('', array_map('ucfirst', explode("_", $command_name)));
+
+		if (! empty($class_name)) {
+			$class_user = '\\App\\Commands\\' . $class_name;
+			$class_fw = '\\KarmaFW\\Commands\\' . $class_name;
+
+			if (class_exists($class_user)) {
+				$command = new $class_user;
+				$command->run($arguments);
+				exit(0);
+
+			} else if (class_exists($class_fw)) {
+				$command = new $class_fw;
+				$command->run($arguments);
+				exit(0);
+
+			} else {
+				echo "PHP Console script" . PHP_EOL . PHP_EOL; 
+				echo "Usage: php console.php <action> [arguments]" . PHP_EOL . PHP_EOL;
+				echo "Warning: invalid action" . PHP_EOL;
+			}
+
+		} else {
+			echo "PHP Console script" . PHP_EOL . PHP_EOL; 
+			echo "Usage: php console.php <action> [arguments]" . PHP_EOL . PHP_EOL;
+			echo "Warning: missing action" . PHP_EOL;
+		}
+
+		exit(1);
+	}
+
 }

+ 7 - 0
src/WebApp.php

@@ -62,7 +62,14 @@ class WebApp extends App
 	*/
 
 
+	// deprecated
 	public static function route()
+	{
+		return self::routeUrl();
+	}
+
+
+	public static function routeUrl()
 	{
 		if (! self::$booted) {
 			self::boot();