Skip to content

Commit

Permalink
Adding some more basic methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 4, 2010
1 parent da632fe commit aef53cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cake/libs/configure.php
Expand Up @@ -266,13 +266,13 @@ public static function delete($var = null) {
*
* `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;
}

/**
Expand All @@ -284,6 +284,21 @@ public static function configured() {
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.
*
Expand Down
2 changes: 2 additions & 0 deletions cake/tests/cases/libs/configure.test.php
Expand Up @@ -269,6 +269,8 @@ function testReaderSetup() {
$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.');
}

/**
Expand Down

0 comments on commit aef53cd

Please sign in to comment.