You are here

public static function FileCacheFactory::get in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/Component/FileCache/FileCacheFactory.php \Drupal\Component\FileCache\FileCacheFactory::get()

Instantiates a FileCache object for a given collection identifier.

Parameters

string $collection: The collection identifier for this FileCache.

array $default_configuration: (optional) The default configuration for this FileCache collection. This can be used to e.g. specify default usage of a FileCache class.

Return value

\Drupal\Component\FileCache\FileCacheInterface The initialized FileCache object.

2 calls to FileCacheFactory::get()
YamlDiscovery::findAll in lib/Drupal/Component/Discovery/YamlDiscovery.php
Returns an array of discoverable items.
YamlFileLoader::__construct in lib/Drupal/Core/DependencyInjection/YamlFileLoader.php

File

lib/Drupal/Component/FileCache/FileCacheFactory.php, line 41
Contains \Drupal\Component\FileCache\FileCacheFactory.

Class

FileCacheFactory
Creates a FileCache object.

Namespace

Drupal\Component\FileCache

Code

public static function get($collection, $default_configuration = array()) {
  $default_configuration += array(
    'class' => '\\Drupal\\Component\\FileCache\\FileCache',
    'collection' => $collection,
    'cache_backend_class' => NULL,
    'cache_backend_configuration' => array(),
  );
  $configuration = array();
  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;
  $class = $configuration['class'];
  return new $class(static::getPrefix(), $configuration['collection'], $configuration['cache_backend_class'], $configuration['cache_backend_configuration']);
}