Skip to content

Commit

Permalink
updating App::objects cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
gwoo committed Jul 25, 2009
1 parent fe569ec commit df6d627
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions cake/libs/configure.php
Expand Up @@ -25,6 +25,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

/**
* Configuration class (singleton). Used for managing runtime configuration information.
*
Expand All @@ -43,14 +44,6 @@ class Configure extends Object {
*/
var $debug = null;

/**
* Determines if $__objects cache should be written.
*
* @var boolean
* @access private
*/
var $__cache = false;

/**
* Returns a singleton instance of the Configure class.
*
Expand Down Expand Up @@ -431,17 +424,6 @@ function __loadBootstrap($boot) {
}
}
}

/**
* Caches the object map when the instance of the Configure class is destroyed
*
* @access public
*/
function __destruct() {
if ($this->__cache) {
Cache::write('object_map', array_filter($this->__objects), '_cake_core_');
}
}
}

/**
Expand Down Expand Up @@ -721,6 +703,7 @@ function core($type = null) {
$paths['cake'][] = $cake;
$paths['libs'][] = $libs;
$paths['models'][] = $libs . 'model' . DS;
$paths['datasources'][] = $libs . 'model' . DS . 'datasources' . DS;
$paths['behaviors'][] = $libs . 'model' . DS . 'behaviors' . DS;
$paths['controllers'][] = $libs . 'controller' . DS;
$paths['components'][] = $libs . 'controller' . DS . 'components' . DS;
Expand Down Expand Up @@ -764,7 +747,7 @@ function objects($type, $path = null, $cache = true) {
$_this->__objects = Cache::read('object_map', '_cake_core_');
}

if (empty($_this->__objects) || !isset($_this->__objects[$type]) || $cache !== true) {
if (!isset($_this->__objects[$name]) || $cache !== true) {
$types = $_this->types;

if (!isset($types[$type])) {
Expand Down Expand Up @@ -792,13 +775,15 @@ function objects($type, $path = null, $cache = true) {
$objects[$key] = Inflector::camelize($value);
}
}
if ($cache === true && !empty($objects)) {

if ($cache === true) {
$_this->__objects[$name] = $objects;
$_this->__cache = true;
} else {
return $objects;
}
}

return $_this->__objects[$name];
}

Expand Down Expand Up @@ -984,12 +969,13 @@ function __find($file, $recursive = true) {
}
continue;
}

if (!isset($this->__paths[$path])) {
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
}
$Folder =& new Folder();
$directories = $Folder->tree($path, false, 'dir');
$directories = $Folder->tree($path, array('.svn', 'tests', 'templates'), 'dir');
$this->__paths[$path] = $directories;
}

Expand Down Expand Up @@ -1173,10 +1159,10 @@ function __settings($type, $plugin, $parent) {
*/
function __paths($type) {
$type = strtolower($type);
$paths = array();

if ($type === 'core') {
$path = App::core();
$paths = array();

foreach ($path as $key => $value) {
$count = count($key);
Expand All @@ -1189,6 +1175,7 @@ function __paths($type) {
if ($paths = App::path($type .'s')) {
return $paths;
}
return $paths;
}

/**
Expand Down Expand Up @@ -1255,6 +1242,7 @@ function __destruct() {
unset($this->__paths[rtrim($core[0], DS)]);
Cache::write('dir_map', array_filter($this->__paths), '_cake_core_');
Cache::write('file_map', array_filter($this->__map), '_cake_core_');
Cache::write('object_map', $this->__objects, '_cake_core_');
}
}
}
Expand Down

0 comments on commit df6d627

Please sign in to comment.