From f5fdbb9e8211500ce8ffc959808b7891646f9f3c Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 9 Jan 2021 14:49:45 -0500 Subject: 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. --- lib/Minz/ExtensionManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') 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(); } -- cgit v1.2.3