Adding some more basic methods.

This commit is contained in:
mark_story 2010-12-04 00:14:55 -05:00
parent da632fe191
commit aef53cd23a
2 changed files with 20 additions and 3 deletions

View file

@ -266,13 +266,13 @@ class Configure {
*
* `Configure::config('ini', new IniReader());`
*
* @param string $alias The name of the reader being configured. This alias is used later to
* @param string $name The name of the reader being configured. This alias is used later to
* read values from a specific reader.
* @param ConfigReaderInterface $reader The reader to append.
* @return void
*/
public static function config($alias, ConfigReaderInterface $reader) {
self::$_readers[$alias] = $reader;
public static function config($name, ConfigReaderInterface $reader) {
self::$_readers[$name] = $reader;
}
/**
@ -284,6 +284,21 @@ class Configure {
return array_keys(self::$_readers);
}
/**
* Remove a configured reader. This will unset the reader
* and make any future attempts to use it cause an Exception.
*
* @param string $name Name of the reader to drop.
* @return boolean Success
*/
public static function drop($name) {
if (!isset(self::$_readers[$name])) {
return false;
}
unset(self::$_readers[$name]);
return true;
}
/**
* Loads a file from app/config/configure_file.php.
*

View file

@ -269,6 +269,8 @@ class ConfigureTest extends CakeTestCase {
$configured = Configure::configured();
$this->assertTrue(in_array('test', $configured));
$this->assertTrue(Configure::drop('test'));
$this->assertFalse(Configure::drop('test'), 'dropping things that do not exist should return false.');
}
/**