mirror of
https://github.com/predis/predis.git
synced 2026-09-15 04:47:01 +00:00
Implement support for using Predis\Options\IOption with Predis\ConnectionParameters.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Predis;
|
||||
|
||||
use Predis\IConnectionParameters;
|
||||
use Predis\Options\IOption;
|
||||
|
||||
class ConnectionParameters implements IConnectionParameters {
|
||||
private static $_defaultParameters;
|
||||
@@ -58,6 +59,10 @@ class ConnectionParameters implements IConnectionParameters {
|
||||
public static function define($parameter, $default, $callable = null) {
|
||||
self::ensureDefaults();
|
||||
self::$_defaultParameters[$parameter] = $default;
|
||||
if ($default instanceof IOption) {
|
||||
self::$_validators[$parameter] = $default;
|
||||
return;
|
||||
}
|
||||
if (!isset($callable)) {
|
||||
unset(self::$_validators[$parameter]);
|
||||
return;
|
||||
@@ -101,7 +106,11 @@ class ConnectionParameters implements IConnectionParameters {
|
||||
}
|
||||
|
||||
public function __get($parameter) {
|
||||
return $this->_parameters[$parameter];
|
||||
$value = $this->_parameters[$parameter];
|
||||
if ($value instanceof IOption) {
|
||||
$this->_parameters[$parameter] = ($value = $value->getDefault());
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function __isset($parameter) {
|
||||
|
||||
Reference in New Issue
Block a user