mirror of
https://github.com/predis/predis.git
synced 2026-09-10 18:37:34 +00:00
Add the ability to define custom handlers for client options and connection parameters.
This commit is contained in:
@@ -30,6 +30,16 @@ class ClientOptions {
|
||||
return self::$_sharedOptions;
|
||||
}
|
||||
|
||||
public static function define($option, Options\IOption $handler) {
|
||||
self::getSharedOptions();
|
||||
self::$_sharedOptions[$option] = $handler;
|
||||
}
|
||||
|
||||
public static function undefine($option) {
|
||||
self::getSharedOptions();
|
||||
unset(self::$_sharedOptions[$option]);
|
||||
}
|
||||
|
||||
private function initialize($options) {
|
||||
$this->_handlers = $this->getOptions();
|
||||
foreach ($options as $option => $value) {
|
||||
@@ -44,10 +54,6 @@ class ClientOptions {
|
||||
return self::getSharedOptions();
|
||||
}
|
||||
|
||||
protected function defineOption($name, Options\IOption $option) {
|
||||
$this->_handlers[$name] = $option;
|
||||
}
|
||||
|
||||
public function __get($option) {
|
||||
if (!isset($this->_options[$option])) {
|
||||
$handler = $this->_handlers[$option];
|
||||
|
||||
@@ -57,6 +57,16 @@ class ConnectionParameters {
|
||||
return self::$_sharedOptions;
|
||||
}
|
||||
|
||||
public static function define($name, Options\IOption $option) {
|
||||
self::getSharedOptions();
|
||||
self::$_sharedOptions[$name] = $option;
|
||||
}
|
||||
|
||||
public static function undefine($name) {
|
||||
self::getSharedOptions();
|
||||
unset(self::$_sharedOptions[$name]);
|
||||
}
|
||||
|
||||
protected function parseURI($uri) {
|
||||
if (!is_string($uri)) {
|
||||
throw new \InvalidArgumentException('URI must be a string');
|
||||
|
||||
Reference in New Issue
Block a user