Просмотр исходного кода

[php7] implemented php.Lib.loadLib()

Alexander Kuzmenko 8 лет назад
Родитель
Сommit
afaf00aa7d
4 измененных файлов с 35 добавлено и 0 удалено
  1. 1 0
      extra/CHANGES.txt
  2. 10 0
      std/php7/Const.hx
  3. 5 0
      std/php7/Global.hx
  4. 19 0
      std/php7/Lib.hx

+ 1 - 0
extra/CHANGES.txt

@@ -8,6 +8,7 @@ xxxx-xx-xx: 3.4.3
 	php7: fix `null` property access (#6281)
 	php7: fix setting values in a map stored in another map (#6257)
 	php7: implemented `php.Lib.mail()`
+	php7: implemented `php.Lib.loadLib()`
 	php/php7: fixed accessing enum constructors on enum type stored to a variable (#6159)
 	php/php7: fix "cannot implement previously implemented interface" (#6208)
 	php: fix invoking functions stored in dynamic static vars (#6158)

+ 10 - 0
std/php7/Const.hx

@@ -299,4 +299,14 @@ extern class Const {
 	static var SQLITE3_OPEN_READONLY : Int;
 	static var SQLITE3_OPEN_READWRITE : Int;
 	static var SQLITE3_OPEN_CREATE : Int;
+	/**
+		@see http://php.net/manual/en/function.glob.php
+	**/
+	static var GLOB_MARK : Int;
+	static var GLOB_NOSORT : Int;
+	static var GLOB_NOCHECK : Int;
+	static var GLOB_NOESCAPE : Int;
+	static var GLOB_BRACE : Int;
+	static var GLOB_ONLYDIR : Int;
+	static var GLOB_ERR : Int;
 }

+ 5 - 0
std/php7/Global.hx

@@ -712,6 +712,11 @@ extern class Global {
 	**/
 	static function dirname( path:String, levels:Int = 1 ) : String;
 
+	/**
+		@see http://php.net/manual/en/function.glob.php
+	**/
+	static function glob( pattern:String, flags:Int = 0 ) : NativeArray;
+
 	/**
 		@see http://php.net/manual/en/function.opendir.php
 	**/

+ 19 - 0
std/php7/Lib.hx

@@ -24,6 +24,8 @@ package php;
 import haxe.ds.StringMap;
 import php.Global;
 import php.Throwable;
+import php.Syntax;
+import php.Const;
 
 /**
 	Platform-specific PHP Library. Provides some platform-specific functions
@@ -140,10 +142,27 @@ class Lib {
 	}
 
 	/**
+<<<<<<< HEAD
 	*  Loads types defined in the specified directory.
  	*/
  	public static function loadLib(pathToLib : String) : Void
  	{
 		throw "Not implemented";
  	}
+=======
+		Loads types defined in the specified directory.
+	**/
+	public static function loadLib(pathToLib : String) : Void {
+		var absolutePath = Global.realpath(pathToLib);
+		if(absolutePath == false) throw 'Failed to read path: $pathToLib';
+		Syntax.foreach(Global.glob('$absolutePath/*.php'), function(_, fileName) {
+			if(!Global.is_dir(fileName)) {
+				Global.require_once(fileName);
+			}
+		});
+		Syntax.foreach(Global.glob('$absolutePath/*', Const.GLOB_ONLYDIR), function(_, dirName) {
+			loadLib(dirName);
+		});
+	}
+>>>>>>> 59e297d... [php7] implemented php.Lib.loadLib()
 }