Make certain config values optional

This commit is contained in:
Timothy Warren 2017-02-28 16:44:02 -05:00
parent 45d5465d6b
commit 27d4954ab9
2 changed files with 4 additions and 5 deletions

View File

@ -45,6 +45,7 @@ structure is like so:
$config = [ $config = [
'driver' => 'null', // null, apcu, redis, memcache, memcached 'driver' => 'null', // null, apcu, redis, memcache, memcached
'connection' => [ 'connection' => [
// Optional (For some drivers):
// driver setup, see below for the structure for each // driver setup, see below for the structure for each
// driver // driver
], ],

View File

@ -307,11 +307,9 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface {
{ {
$driver = ucfirst(strtolower($driverConfig['driver'])); $driver = ucfirst(strtolower($driverConfig['driver']));
$class = __NAMESPACE__ . "\\Driver\\${driver}Driver"; $class = __NAMESPACE__ . "\\Driver\\${driver}Driver";
if ( ! array_key_exists('options', $driverConfig)) $driverConfig['connection'] = $driverConfig['connection'] ?? [];
{ $driverConfig['options'] = $driverConfig['options'] ?? [];
$driverConfig['options'] = [];
}
return new $class($driverConfig['connection'], $driverConfig['options']); return new $class($driverConfig['connection'], $driverConfig['options']);
} }