MDL-56971 enrol: Use autoloading in enrol_get_plugin()
authorMichael Aherne <michael.aherne@strath.ac.uk>
Tue, 15 Nov 2016 12:22:54 +0000 (12:22 +0000)
committerMichael Aherne <michael.aherne@strath.ac.uk>
Tue, 15 Nov 2016 12:22:54 +0000 (12:22 +0000)
lib/enrollib.php

index 4849b07..452a899 100644 (file)
@@ -145,13 +145,15 @@ function enrol_get_plugin($name) {
 
     $location = "$CFG->dirroot/enrol/$name";
 
-    if (!file_exists("$location/lib.php")) {
-        return null;
-    }
-    include_once("$location/lib.php");
     $class = "enrol_{$name}_plugin";
     if (!class_exists($class)) {
-        return null;
+        if (!file_exists("$location/lib.php")) {
+            return null;
+        }
+        include_once("$location/lib.php");
+        if (!class_exists($class)) {
+            return null;
+        }
     }
 
     return new $class();