"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Config/ReadOnlyStorage.php" (26 Nov 2020, 2359 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ReadOnlyStorage.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Config;
    4 
    5 /**
    6  * A ReadOnlyStorage decorates a storage and does not allow writing to it.
    7  */
    8 class ReadOnlyStorage implements StorageInterface {
    9 
   10   /**
   11    * The config storage that we are decorating.
   12    *
   13    * @var \Drupal\Core\Config\StorageInterface
   14    */
   15   protected $storage;
   16 
   17   /**
   18    * Create a ReadOnlyStorage decorating another storage.
   19    *
   20    * @param \Drupal\Core\Config\StorageInterface $storage
   21    *   The decorated storage.
   22    */
   23   public function __construct(StorageInterface $storage) {
   24     $this->storage = $storage;
   25   }
   26 
   27   /**
   28    * {@inheritdoc}
   29    */
   30   public function exists($name) {
   31     return $this->storage->exists($name);
   32   }
   33 
   34   /**
   35    * {@inheritdoc}
   36    */
   37   public function read($name) {
   38     return $this->storage->read($name);
   39   }
   40 
   41   /**
   42    * {@inheritdoc}
   43    */
   44   public function readMultiple(array $names) {
   45     return $this->storage->readMultiple($names);
   46   }
   47 
   48   /**
   49    * {@inheritdoc}
   50    */
   51   public function write($name, array $data) {
   52     throw new \BadMethodCallException(__METHOD__ . ' is not allowed on a ReadOnlyStorage');
   53   }
   54 
   55   /**
   56    * {@inheritdoc}
   57    */
   58   public function delete($name) {
   59     throw new \BadMethodCallException(__METHOD__ . ' is not allowed on a ReadOnlyStorage');
   60   }
   61 
   62   /**
   63    * {@inheritdoc}
   64    */
   65   public function rename($name, $new_name) {
   66     throw new \BadMethodCallException(__METHOD__ . ' is not allowed on a ReadOnlyStorage');
   67   }
   68 
   69   /**
   70    * {@inheritdoc}
   71    */
   72   public function encode($data) {
   73     return $this->storage->encode($data);
   74   }
   75 
   76   /**
   77    * {@inheritdoc}
   78    */
   79   public function decode($raw) {
   80     return $this->storage->decode($raw);
   81   }
   82 
   83   /**
   84    * {@inheritdoc}
   85    */
   86   public function listAll($prefix = '') {
   87     return $this->storage->listAll($prefix);
   88   }
   89 
   90   /**
   91    * {@inheritdoc}
   92    */
   93   public function deleteAll($prefix = '') {
   94     throw new \BadMethodCallException(__METHOD__ . ' is not allowed on a ReadOnlyStorage');
   95   }
   96 
   97   /**
   98    * {@inheritdoc}
   99    */
  100   public function createCollection($collection) {
  101     return new static($this->storage->createCollection($collection));
  102   }
  103 
  104   /**
  105    * {@inheritdoc}
  106    */
  107   public function getAllCollectionNames() {
  108     return $this->storage->getAllCollectionNames();
  109   }
  110 
  111   /**
  112    * {@inheritdoc}
  113    */
  114   public function getCollectionName() {
  115     return $this->storage->getCollectionName();
  116   }
  117 
  118 }