noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 29/46: Use autoload


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 29/46: Use autoload
Date: Tue, 13 Jul 2021 05:01:58 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit da467c9762759f016608b21089fd977f7dd62d63
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Jun 20 01:05:35 2021 +0200

    Use autoload
---
 include/constant.php | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/constant.php b/include/constant.php
index 9a1eeae..1d7d72c 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -357,3 +357,22 @@ if ( ! defined ("NOALYSS_URL")) {
 if (!defined ("DEFAULT_SERVER_VIDEO_CONF")) {
     define ("DEFAULT_SERVER_VIDEO_CONF","https://www.free-solutions.org/";);
 }
+/**
+ * @brief load automatically class
+ * 
+ * @param string $class classname to load
+ */
+function noalyss_class_autoloader($class) {
+    echo "class to load $class";
+    $class=strtolower($class);
+    $aClass = array(
+        "database"=>"/class/database.class.php",
+        "user"=>"/class/user.class.php"
+    );
+    if ( isset ($aClass[$class]) ) {
+        require_once NOALYSS_INCLUDE.$aClass[$class];
+    }
+    
+}
+
+spl_autoload_register('\noalyss_class_autoloader',true);
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]