You are here

class PhpStorageFactory in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php \Drupal\Core\PhpStorage\PhpStorageFactory

Creates a php storage object

Hierarchy

Expanded class hierarchy of PhpStorageFactory

7 files declare their use of PhpStorageFactory
common.inc in core/includes/common.inc
Common functions that many Drupal modules will need to reference.
PhpBackend.php in core/lib/Drupal/Core/Cache/PhpBackend.php
Contains \Drupal\Core\Cache\PhpBackend.
PhpStorageFactoryTest.php in core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
Contains \Drupal\system\Tests\PhpStorage\PhpStorageFactoryTest.
system.module in core/modules/system/system.module
Configuration system that lets administrators modify the workings of the site.
TwigPhpStorageCache.php in core/lib/Drupal/Core/Template/TwigPhpStorageCache.php
Contains \Drupal\Core\Template\TwigPhpStorageCache.

... See full list

File

core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php, line 16
Contains \Drupal\Core\PhpStorage\PhpStorageFactory.

Namespace

Drupal\Core\PhpStorage
View source
class PhpStorageFactory {

  /**
   * 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.
   *
   * @param 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 \Drupal\Component\PhpStorage\PhpStorageInterface
   *   An instantiated storage for the specified name.
   */
  static function get($name) {
    $overrides = Settings::get('php_storage');
    if (isset($overrides[$name])) {
      $configuration = $overrides[$name];
    }
    elseif (isset($overrides['default'])) {
      $configuration = $overrides['default'];
    }
    else {
      $configuration = array(
        'class' => 'Drupal\\Component\\PhpStorage\\MTimeProtectedFileStorage',
        'secret' => Settings::getHashSalt(),
      );
    }
    $class = isset($configuration['class']) ? $configuration['class'] : 'Drupal\\Component\\PhpStorage\\MTimeProtectedFileStorage';
    if (!isset($configuration['bin'])) {
      $configuration['bin'] = $name;
    }
    if (!isset($configuration['directory'])) {
      $configuration['directory'] = PublicStream::basePath() . '/php';
    }
    return new $class($configuration);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpStorageFactory::get static function Instantiates a storage for generated PHP code.