Robert Vogel has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/276407

Change subject: ExtensionManager: Use autoloader #2
......................................................................

ExtensionManager: Use autoloader #2

Rewrite of ExtensionManager to use autoloader.

Change-Id: Idbad7dc69086ef507aebaa780e1b860a8fa2a466
---
M includes/ExtensionManager.class.php
1 file changed, 23 insertions(+), 23 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/07/276407/1

diff --git a/includes/ExtensionManager.class.php 
b/includes/ExtensionManager.class.php
index d9c6935..a50905b 100644
--- a/includes/ExtensionManager.class.php
+++ b/includes/ExtensionManager.class.php
@@ -18,7 +18,6 @@
        protected static $prRunningExtensions = array();
        protected static $aContexts = array();
        protected static $aActiveContexts = array();
-       protected static $aIncludedClasses = array();
 
        public static function addContext( $sKey ) {
                wfProfileIn( 'Performance: ' . __METHOD__ );
@@ -85,29 +84,30 @@
                $path = "$IP/extensions/BlueSpiceExtensions";
 
                foreach ( self::$prRegisteredExtensions as $extension => 
$attributes ) {
-                               /* -- reverted, this doesn't work
-                               //if possible, load by autoloader
-                               if( class_exists( 'Bs' . $extension ) || 
class_exists( $extension ) ) {
-                                       continue;
-                               }
-                               */
-                               if ( $attributes['baseDir'] != 'ext' ) {
-                                       require( $attributes['baseDir'] . DS . 
$extension . '.class.php' );
-                               } else {
-                                       require( $path . DS . $extension . DS . 
$extension . '.class.php' );
-                               }
-                               self::$aIncludedClasses[] = $extension;
-               }
+                               $sClassName = $extension;
 
-               foreach ( self::$aIncludedClasses as $key => $value ) {
-                       if ( class_exists( 'Bs' . $value, false ) ) {
-                               $class = 'Bs' . $value;
-                       } else {
-                               $class = $value;
-                       }
-                       self::$prRunningExtensions[$value] = new $class();
-                       self::$prRunningExtensions[$value]->setCore( $oCore );
-                       self::$prRunningExtensions[$value]->setup();
+                               //Check if autoloader knows class with 
extension name and if it
+                               //is of type 'BsExtensionMW'
+                               if ( !is_subclass_of( $sClassName, 
'BsExtensionMW' ) ) {
+                                       //Check if autoloader knows a prefixed 
class name
+                                       $sClassName = 'Bs'.$sClassName;
+                                       if ( !is_subclass_of( $sClassName, 
'BsExtensionMW' ) ) {
+                                               if ( $attributes['baseDir'] != 
'ext' ) {
+                                                       require( 
$attributes['baseDir'] . DS . $extension . '.class.php' );
+                                               } else {
+                                                       require( $path . DS . 
$extension . DS . $extension . '.class.php' );
+                                               }
+                                               //Now we only need to check 
whether to use the prefixed or
+                                               //the unprefixed extension name 
as class name for instantiation
+                                               if( !class_exists( $sClassName, 
false ) ) {
+                                                       $sClassName = 
$extension;
+                                               }
+                                       }
+                               }
+
+                               self::$prRunningExtensions[$extension] = new 
$sClassName();
+                               
self::$prRunningExtensions[$extension]->setCore( $oCore );
+                               self::$prRunningExtensions[$extension]->setup();
                }
 
                wfProfileOut( 'Performance: ' . __METHOD__ );

-- 
To view, visit https://gerrit.wikimedia.org/r/276407
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbad7dc69086ef507aebaa780e1b860a8fa2a466
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to