aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-01-09 14:49:45 -0500
committerGravatar GitHub <noreply@github.com> 2021-01-09 20:49:45 +0100
commitf5fdbb9e8211500ce8ffc959808b7891646f9f3c (patch)
treebe6343f5ff7e19883b9a17fa068afc7aa2439095 /lib
parent896f9d33637ec510937bc13a34f98f669795ab49 (diff)
Add class autoload for extension (#3350)
When an extension defines an `autoload` method, it will be registered automatically before enabling the extension. For the extension creator, it's easier because there is no need to register it manually.
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ExtensionManager.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index e802aad16..2a68f8393 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -188,7 +188,7 @@ class Minz_ExtensionManager {
* Add the extension to the list of the known extensions ($ext_list).
*
* If the extension is present in $ext_auto_enabled and if its type is "system",
- * it will be enabled in the same time.
+ * it will be enabled at the same time.
*
* @param Minz_Extension $ext a valid extension.
*/
@@ -216,6 +216,10 @@ class Minz_ExtensionManager {
if (isset(self::$ext_list[$ext_name])) {
$ext = self::$ext_list[$ext_name];
self::$ext_list_enabled[$ext_name] = $ext;
+
+ if (method_exists($ext, 'autoload')) {
+ spl_autoload_register([$ext, 'autoload']);
+ }
$ext->enable();
$ext->init();
}