static function PhpStorageFactory::get

Instantiates a storage controller for generated PHP code.

By default, this returns an instance of the \Drupal\Component\PhpStorage\MTimeProtectedFileStorage class.

Classes implementing \Drupal\Component\PhpStorage\PhpStorageInterface can be registered for a specific bin or as a default implementation.

Parameters

string $name: The name for which the storage controller should be returned. Defaults to 'default'. The name is also used as the storage bin if one is not specified in the configuration.

Return value

\Drupal\Component\PhpStorage\PhpStorageInterface An instantiated storage controller for the specified name.

2 calls to PhpStorageFactory::get()
DrupalKernel::storage in drupal/core/lib/Drupal/Core/DrupalKernel.php
Gets the PHP code storage object to use for the compiled container.
TwigEnvironment::storage in drupal/core/lib/Drupal/Core/Template/TwigEnvironment.php
Gets the PHP code storage object to use for the compiled Twig files.

File

drupal/core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php, line 33
Definition of Drupal\Component\PhpStorage\PhpStorageFactory.

Class

PhpStorageFactory
Creates a php storage object

Namespace

Drupal\Component\PhpStorage

Code

static function get($name) {
  global $conf;
  if (isset($conf['php_storage'][$name])) {
    $configuration = $conf['php_storage'][$name];
  }
  elseif (isset($conf['php_storage']['default'])) {
    $configuration = $conf['php_storage']['default'];
  }
  else {
    $configuration = array(
      'class' => 'Drupal\\Component\\PhpStorage\\MTimeProtectedFileStorage',
      'secret' => $GLOBALS['drupal_hash_salt'],
    );
  }
  $class = isset($configuration['class']) ? $configuration['class'] : 'Drupal\\Component\\PhpStorage\\MTimeProtectedFileStorage';
  if (!isset($configuration['bin'])) {
    $configuration['bin'] = $name;
  }
  if (!isset($configuration['directory'])) {
    $path = isset($conf['file_public_path']) ? $conf['file_public_path'] : conf_path() . '/files';
    $configuration['directory'] = DRUPAL_ROOT . "/{$path}/php";
  }
  return new $class($configuration);
}