Adding a parameter to configured() to allow you to check if a particular config has been configured.

This commit is contained in:
mark_story 2010-12-04 22:57:33 -05:00
parent 0b18fc25a6
commit 5ad8d8af41
2 changed files with 8 additions and 1 deletions

View file

@ -284,7 +284,10 @@ class Configure {
*
* @return array Array of the configured reader objects.
*/
public static function configured() {
public static function configured($name = null) {
if ($name) {
return isset(self::$_readers[$name]);
}
return array_keys(self::$_readers);
}

View file

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