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 = [
'driver' => 'null', // null, apcu, redis, memcache, memcached
'connection' => [
// Optional (For some drivers):
// driver setup, see below for the structure for each
// driver
],

View File

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