Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid creating multiple instances of ClassLoader.

  • Loading branch information...
commit 29c2b25d73061e5b8615ef567e08e72dc7193286 1 parent 91c463d
@ADmad ADmad authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/Core/Plugin.php
View
15 src/Core/Plugin.php
@@ -35,6 +35,13 @@ class Plugin {
protected static $_plugins = [];
/**
+ * Class loader instance
+ *
+ * @var \Cake\Core\ClassLoader
+ */
+ protected static $_loader;
+
+/**
* Loads a plugin and optionally loads bootstrapping,
* routing files or runs a initialization function.
*
@@ -140,9 +147,11 @@ public static function load($plugin, $config = []) {
}
if ($config['autoload'] === true) {
- $loader = new ClassLoader;
- $loader->register();
- $loader->addNamespace($config['namespace'], $config['path']);
+ if (empty(static::$_loader)) {
+ static::$_loader = new ClassLoader;
+ static::$_loader->register();
+ }
+ static::$_loader->addNamespace($config['namespace'], $config['path']);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.