Skip to content

Commit

Permalink
Don't reload already loaded plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 10, 2013
1 parent 09b22b4 commit 261b08a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Cake/Core/Plugin.php
Expand Up @@ -158,6 +158,8 @@ public static function load($plugin, $config = array()) {
* The above example will load the bootstrap file for all plugins, but for DebugKit it will only load the routes file
* and will not look for any bootstrap script.
*
* If a plugin has been loaded already, it will not be reloaded by loadAll().
*
* @param array $options
* @return void
*/
Expand All @@ -168,6 +170,9 @@ public static function loadAll($options = []) {
if ($opts === null && isset($options[0])) {
$opts = $options[0];
}
if (isset(static::$_plugins[$p])) {
continue;
}
static::load($p, (array)$opts);
}
}
Expand Down
11 changes: 11 additions & 0 deletions lib/Cake/Test/TestCase/Core/PluginTest.php
Expand Up @@ -249,6 +249,17 @@ public function testLoadAll() {
$this->assertEquals($expected, Plugin::loaded());
}

/**
* Test that plugins don't reload using loadAll();
*
* @return void
*/
public function testLoadAllWithPluginAlreadyLoaded() {
Plugin::load('PluginJs', ['namespace' => 'Company\TestPluginJs']);
Plugin::loadAll();
$this->assertEquals('Company\TestPluginJs', Plugin::getNamespace('PluginJs'));
}

/**
* Tests that Plugin::loadAll() will load all plgins in the configured folder with bootstrap loading
*
Expand Down

0 comments on commit 261b08a

Please sign in to comment.