mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding some more basic methods.
This commit is contained in:
parent
da632fe191
commit
aef53cd23a
2 changed files with 20 additions and 3 deletions
|
@ -266,13 +266,13 @@ class Configure {
|
||||||
*
|
*
|
||||||
* `Configure::config('ini', new IniReader());`
|
* `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.
|
* read values from a specific reader.
|
||||||
* @param ConfigReaderInterface $reader The reader to append.
|
* @param ConfigReaderInterface $reader The reader to append.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function config($alias, ConfigReaderInterface $reader) {
|
public static function config($name, ConfigReaderInterface $reader) {
|
||||||
self::$_readers[$alias] = $reader;
|
self::$_readers[$name] = $reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,6 +284,21 @@ class Configure {
|
||||||
return array_keys(self::$_readers);
|
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.
|
* Loads a file from app/config/configure_file.php.
|
||||||
*
|
*
|
||||||
|
|
|
@ -269,6 +269,8 @@ class ConfigureTest extends CakeTestCase {
|
||||||
$configured = Configure::configured();
|
$configured = Configure::configured();
|
||||||
|
|
||||||
$this->assertTrue(in_array('test', $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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue