static PhpStorageFactory::get($name)
Instantiates a storage 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 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 for the specified name.
File
- core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php, line 31
Class
- PhpStorageFactory
- Creates a php storage object
Namespace
Drupal\Core\PhpStorage
Code
static function get($name) { $configuration = array(); $overrides = Settings::get('php_storage'); if (isset($overrides[$name])) { $configuration = $overrides[$name]; } elseif (isset($overrides['default'])) { $configuration = $overrides['default']; } // Make sure all the necessary configuration values are set. $class = isset($configuration['class']) ? $configuration['class'] : 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage'; if (!isset($configuration['secret'])) { $configuration['secret'] = Settings::getHashSalt(); } if (!isset($configuration['bin'])) { $configuration['bin'] = $name; } if (!isset($configuration['directory'])) { $configuration['directory'] = PublicStream::basePath() . '/php'; } return new $class($configuration); }
Please login to continue.