Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
|
@ -7,6 +7,11 @@ namespace Drupal\Component\FileCache;
|
|||
*/
|
||||
class FileCacheFactory {
|
||||
|
||||
/**
|
||||
* The configuration key to disable FileCache completely.
|
||||
*/
|
||||
const DISABLE_CACHE = 'file_cache_disable';
|
||||
|
||||
/**
|
||||
* The configuration used to create FileCache objects.
|
||||
*
|
||||
|
@ -34,23 +39,35 @@ class FileCacheFactory {
|
|||
* The initialized FileCache object.
|
||||
*/
|
||||
public static function get($collection, $default_configuration = []) {
|
||||
$default_configuration += [
|
||||
// If there is a special key in the configuration, disable FileCache completely.
|
||||
if (!empty(static::$configuration[static::DISABLE_CACHE])) {
|
||||
return new NullFileCache('', '');
|
||||
}
|
||||
|
||||
$configuration = [];
|
||||
|
||||
// Check for a collection specific setting first.
|
||||
if (isset(static::$configuration[$collection])) {
|
||||
$configuration += static::$configuration[$collection];
|
||||
}
|
||||
// Then check if a default configuration has been provided.
|
||||
if (!empty($default_configuration)) {
|
||||
$configuration += $default_configuration;
|
||||
}
|
||||
// Last check if a default setting has been provided.
|
||||
if (isset(static::$configuration['default'])) {
|
||||
$configuration += static::$configuration['default'];
|
||||
}
|
||||
|
||||
// Ensure that all properties are set.
|
||||
$fallback_configuration = [
|
||||
'class' => '\Drupal\Component\FileCache\FileCache',
|
||||
'collection' => $collection,
|
||||
'cache_backend_class' => NULL,
|
||||
'cache_backend_configuration' => [],
|
||||
];
|
||||
|
||||
$configuration = [];
|
||||
if (isset(static::$configuration[$collection])) {
|
||||
$configuration = static::$configuration[$collection];
|
||||
}
|
||||
elseif (isset(static::$configuration['default'])) {
|
||||
$configuration = static::$configuration['default'];
|
||||
}
|
||||
|
||||
// Add defaults to the configuration.
|
||||
$configuration = $configuration + $default_configuration;
|
||||
$configuration = $configuration + $fallback_configuration;
|
||||
|
||||
$class = $configuration['class'];
|
||||
return new $class(static::getPrefix(), $configuration['collection'], $configuration['cache_backend_class'], $configuration['cache_backend_configuration']);
|
||||
|
|
Reference in a new issue