Navigation Menu

Skip to content

Commit

Permalink
Using keyword self instead of Configure, removing use of File class i…
Browse files Browse the repository at this point in the history
…n favor of SplFileObject
  • Loading branch information
lorenzo committed Jul 23, 2010
1 parent 766d7d5 commit 88ea68a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions cake/libs/configure.php
Expand Up @@ -249,7 +249,7 @@ public static function load($fileName) {
trigger_error(sprintf(__('Configure::load() - no variable $config found in %s.php'), $fileName), E_USER_WARNING);
return false;
}
return Configure::write($config);
return self::write($config);
}

/**
Expand All @@ -263,7 +263,7 @@ public static function load($fileName) {
public static function version() {
if (!isset(self::$_values['Cake']['version'])) {
require(CORE_PATH . 'cake' . DS . 'config' . DS . 'config.php');
Configure::write($config);
self::write($config);
}
return self::$_values['Cake']['version'];
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public static function store($type, $name, $data = array()) {
if (is_null($type)) {
$write = false;
}
Configure::__writeConfig($content, $name, $write);
self::__writeConfig($content, $name, $write);
}

/**
Expand All @@ -308,7 +308,7 @@ public static function store($type, $name, $data = array()) {
private static function __writeConfig($content, $name, $write = true) {
$file = CACHE . 'persistent' . DS . $name . '.php';

if (Configure::read('debug') > 0) {
if (self::read('debug') > 0) {
$expires = "+10 seconds";
} else {
$expires = "+999 days";
Expand All @@ -320,13 +320,9 @@ private static function __writeConfig($content, $name, $write = true) {
}

if ($write === true) {
if (!class_exists('File')) {
require LIBS . 'file.php';
}
$fileClass = new File($file);

if ($fileClass->writable()) {
$fileClass->append($content);
$fileClass = new SplFileObject($file, 'a');
if ($fileClass->isWritable()) {
$fileClass->fwrite($content);
}
}
}
Expand Down

0 comments on commit 88ea68a

Please sign in to comment.