Browse Source

* Add App::import_all helper static function
* Move release to __destruct in orm abstract base class

Nathaniel van Diepen 7 years ago
parent
commit
9627886e1d
2 changed files with 14 additions and 5 deletions
  1. 8 0
      app.class.php
  2. 6 5
      orm.abstract.class.php

+ 8 - 0
app.class.php

@@ -55,6 +55,14 @@
 				parent::__destruct();
 			}
 		}
+		public static function import_all(string $dirpath){
+			foreach(scandir($dirpath) as $file){
+				$path = "{$dirpath}{$file}";
+				if(is_file($path) && pathinfo($file, PATHINFO_EXTENSION) == "php"){
+					require_once($path);
+				}
+			}
+		}
 		public static function shutdown(){
 			$verb = $_SERVER['REQUEST_METHOD'];
 			if(isset($_SERVER['REDIRECT_URL'])){

+ 6 - 5
orm.abstract.class.php

@@ -55,6 +55,12 @@
 				$this->_data[self::$primary_key] = intval($idOrData);
 			}
 		}
+		public function __destruct(){
+			$this->__sleep();
+			$this->_changed = [];
+			$this->_data = [];
+			$this->_related = [];
+		}
 		public function __get(string $name){
 			switch($name){
 				case 'name':
@@ -229,10 +235,5 @@
 				return in_array($key, $this->_changed);
 			}
 		}
-		public function release(){
-			$this->__sleep();
-			$this->_changed = [];
-			$this->_data = [];
-		}
 	}
 ?>