class FileReadOnlyStorage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php \Drupal\Component\PhpStorage\FileReadOnlyStorage
 
Reads code as regular PHP files, but won't write them.
Hierarchy
- class \Drupal\Component\PhpStorage\FileReadOnlyStorage implements PhpStorageInterface
 
Expanded class hierarchy of FileReadOnlyStorage
1 file declares its use of FileReadOnlyStorage
- FileStorageReadOnlyTest.php in core/
tests/ Drupal/ Tests/ Component/ PhpStorage/ FileStorageReadOnlyTest.php  - Contains \Drupal\Tests\Component\PhpStorage\FileStorageReadOnlyTest.
 
File
- core/
lib/ Drupal/ Component/ PhpStorage/ FileReadOnlyStorage.php, line 13  - Contains \Drupal\Component\PhpStorage\FileReadOnlyStorage.
 
Namespace
Drupal\Component\PhpStorageView source
class FileReadOnlyStorage implements PhpStorageInterface {
  /**
   * The directory where the files should be stored.
   *
   * @var string
   */
  protected $directory;
  /**
   * Constructs this FileStorage object.
   *
   * @param $configuration
   *   An associative array, containing at least two keys (the rest are ignored):
   *   - directory: The directory where the files should be stored.
   *   - bin: The storage bin. Multiple storage objects can be instantiated with
   *   the same configuration, but for different bins.
   */
  public function __construct(array $configuration) {
    $this->directory = $configuration['directory'] . '/' . $configuration['bin'];
  }
  /**
   * {@inheritdoc}
   */
  public function exists($name) {
    return file_exists($this
      ->getFullPath($name));
  }
  /**
   * {@inheritdoc}
   */
  public function load($name) {
    // The FALSE returned on failure is enough for the caller to handle this,
    // we do not want a warning too.
    return @(include_once $this
      ->getFullPath($name)) !== FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function save($name, $code) {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function delete($name) {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getFullPath($name) {
    return $this->directory . '/' . $name;
  }
  /**
   * {@inheritdoc}
   */
  function writeable() {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function deleteAll() {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function listAll() {
    $names = array();
    if (file_exists($this->directory)) {
      foreach (new \DirectoryIterator($this->directory) as $fileinfo) {
        if (!$fileinfo
          ->isDot()) {
          $name = $fileinfo
            ->getFilename();
          if ($name != '.htaccess') {
            $names[] = $name;
          }
        }
      }
    }
    return $names;
  }
  /**
   * {@inheritdoc}
   */
  public function garbageCollection() {
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            FileReadOnlyStorage:: | 
                  protected | property | The directory where the files should be stored. | |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Deletes PHP code from storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Removes all files in this bin. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Checks whether the PHP code exists in storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Performs garbage collection on the storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Gets the full file path. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Lists all the files in the storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Loads PHP code from storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  public | function | 
            Saves PHP code to storage. Overrides PhpStorageInterface:: | 
                  |
| 
            FileReadOnlyStorage:: | 
                  function | 
            Whether this is a writeable storage. Overrides PhpStorageInterface:: | 
                  ||
| 
            FileReadOnlyStorage:: | 
                  public | function | Constructs this FileStorage object. |