Skip to content

Commit

Permalink
Caching plugin objects in App::objects()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 9, 2011
1 parent cd28f19 commit ca4ee0c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Cake/Core/App.php
Expand Up @@ -411,7 +411,7 @@ public static function core($type = null) {
* `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');`
*
* You can also search only within a plugin's objects by using the plugin dot
* syntax (these objects are not cached):
* syntax.
*
* `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');`
*
Expand Down Expand Up @@ -453,7 +453,9 @@ public static function objects($type, $path = null, $cache = true) {
self::$__objects = Cache::read('object_map', '_cake_core_');
}

if (!isset(self::$__objects[$name]) || $cache !== true) {
$cacheLocation = empty($plugin) ? 'app' : $plugin;

if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) {
$objects = array();

if (empty($path)) {
Expand Down Expand Up @@ -484,11 +486,11 @@ public static function objects($type, $path = null, $cache = true) {
if ($plugin) {
return $objects;
}
self::$__objects[$name] = $objects;
self::$__objects[$cacheLocation][$name] = $objects;
self::$_objectCacheChange = true;
}

return self::$__objects[$name];
return self::$__objects[$cacheLocation][$name];
}

/**
Expand Down

0 comments on commit ca4ee0c

Please sign in to comment.