From 0be0b6b258ee568804f85eebeac54dc246eaf0ce Mon Sep 17 00:00:00 2001 From: Joe White Date: Tue, 23 Feb 2021 15:03:27 -0500 Subject: [PATCH] Use the composer autoloader to load files. This change switches the XDMoD code to be loaded with the composer loader rather than the hybrid composer and require and custom loader. The main reason for this change is to switch the ETL directory to use a psr-4 loader thus allowing xdmod modules to extend the ETL framework. Previously it was not possible for a module to add a new DataEndpoint due to the way classes were loaded. The Appkernels module still uses the linker.json so this code path is not modified at this time. Also there was an unused file classes/DB/DBModel/TableColumn.php rather than add this to the loader path I just removed it. Also I switched on the optimizer for composer. --- classes/DB/DBModel/TableColumn.php | 60 ------------------------------ composer.json | 57 +++++++++++++++++++++++++++- configuration/linker.json | 8 ---- configuration/linker.php | 15 +------- 4 files changed, 56 insertions(+), 84 deletions(-) delete mode 100644 classes/DB/DBModel/TableColumn.php diff --git a/classes/DB/DBModel/TableColumn.php b/classes/DB/DBModel/TableColumn.php deleted file mode 100644 index 802f0099d4..0000000000 --- a/classes/DB/DBModel/TableColumn.php +++ /dev/null @@ -1,60 +0,0 @@ -_name = $name; - $this->_type = $type; - $this->_formula = $formula; - $this->_in_group_by = $in_group_by; - $this->_in_cube = $in_cube; - $this->_in_index = $in_index; - $this->_comment = $comment; - } - - public function __toString() - { - return $this->_name; - } - public function getName() - { - return $this->_name; - } - public function getType() - { - return $this->_type; - } - public function getFormula() - { - if(strlen($this->_formula) > 0) return $this->_formula; - return $this->_name; - } - public function isInGroupBy() - { - return $this->_in_group_by; - } - public function isInCube() - { - return $this->_in_cube; - } - public function getComment() - { - return $this->_comment; - } -} - -?> \ No newline at end of file diff --git a/composer.json b/composer.json index 68d85be70f..8f5e88d470 100644 --- a/composer.json +++ b/composer.json @@ -224,11 +224,64 @@ "platform": { "php": "5.4" }, + "optimize-autoloader": true, + "apcu-autoloader": true, "secure-http": false }, "autoload": { + "files": [ + "configuration/constants.php", + "libraries/response.php", + "libraries/debug.php", + "libraries/web_message.php", + "libraries/rest.php", + "libraries/versioning.php", + "libraries/date.php", + "libraries/utilities.php", + "libraries/dashboard.php", + "libraries/security.php", + "libraries/regression.php", + "libraries/conversions.php", + "libraries/controller.php", + "libraries/domdocument.php", + "libraries/charting.php" + ], "classmap": [ - "classes" - ] + "classes/DataWarehouse.php", + "classes/XDChartPool.php", + "classes/XDStatistics.php", + "classes/SessionExpiredException.php", + "classes/XDController.php", + "classes/XDUser.php", + "classes/UniqueException.php", + "classes/XDError.php", + "classes/XDUserProfile.php", + "classes/UserException.php", + "classes/XDException.php", + "classes/XDWarehouse.php", + "classes/UserStorage.php", + "classes/XDReportManager.php", + "classes/XDAdmin.php", + "classes/XDSessionManager.php", + "classes/ExtJS", + "classes/DB" + ], + "psr-4": { + "Authentication\\": "classes/Authentication/", + "CCR\\": "classes/CCR/", + "Common\\": "classes/Common/", + "Configuration\\": "classes/Configuration/", + "DataWarehouse\\": "classes/DataWarehouse/", + "ETL\\": "classes/ETL/", + "Log\\": "classes/Log/", + "Models\\": "classes/Models/", + "OpenXdmod\\": "classes/OpenXdmod/", + "Realm\\": "classes/Realm/", + "ReportTemplates\\": "classes/ReportTemplates/", + "Reports\\": "classes/Reports/", + "Rest\\": "classes/Rest/", + "User\\": "classes/User/", + "Xdmod\\": "classes/Xdmod/" + } } } diff --git a/configuration/linker.json b/configuration/linker.json index 163804bd4c..f5e578a809 100644 --- a/configuration/linker.json +++ b/configuration/linker.json @@ -1,12 +1,4 @@ { "include_dirs": [ - "classes", - "classes/DB", - "classes/DB/DBModel", - "classes/DB/TimePeriodGenerators", - "classes/ExtJS", - "classes/Rest", - "classes/User", - "classes/ReportTemplates" ] } diff --git a/configuration/linker.php b/configuration/linker.php index 79566d01b0..1236e9cb4c 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -2,11 +2,8 @@ use CCR\Log; -$dir = dirname(__FILE__); -$baseDir = dirname($dir); +$baseDir = dirname(dirname(__FILE__)); -require_once($dir . '/constants.php'); -require_once($baseDir . '/libraries/utilities.php'); require_once($baseDir . "/vendor/autoload.php"); $linkerConfig = \Configuration\XdmodConfiguration::assocArrayFactory('linker.json', CONFIG_DIR); @@ -47,16 +44,6 @@ function xdmodAutoload($className) spl_autoload_register('xdmodAutoload'); -$libraries = scandir($baseDir . '/libraries'); - -foreach ($libraries as $library) { - $file = "$baseDir/libraries/$library"; - if (is_dir($file)) { - continue; - } - require_once($file); -} - class HttpCodeMessages { // HTTP 1.1 messages from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html