You are here

class SourceStorage in Configuration installer 8

Wraps the sync storage so the config_installer can make modifications.

Hierarchy

Expanded class hierarchy of SourceStorage

2 files declare their use of SourceStorage
config_installer.profile in ./config_installer.profile
Enables modules and site configuration for a minimal site installation.
SyncConfigureForm.php in src/Form/SyncConfigureForm.php

File

src/Storage/SourceStorage.php, line 11

Namespace

Drupal\config_installer\Storage
View source
class SourceStorage implements StorageInterface {
  use DependencySerializationTrait;

  /**
   * The configuration storage to wrap.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $baseStorage;

  /**
   * The available install profiles.
   *
   * @var array
   */
  protected $profiles;

  /**
   * Constructs a SourceStorage object.
   *
   * @param \Drupal\Core\Config\StorageInterface $base_storage
   *   The configuration storage to wrap.
   * @param array $profiles
   *   The available install profiles.
   */
  public function __construct(StorageInterface $base_storage, array $profiles) {
    $this->baseStorage = $base_storage;
    $this->profiles = $profiles;
  }

  /**
   * {@inheritdoc}
   */
  public function exists($name) {
    return $this->baseStorage
      ->exists($name);
  }

  /**
   * {@inheritdoc}
   */
  public function read($name) {
    $data = $this->baseStorage
      ->read($name);
    if ($name === 'core.extension' && isset($data['module'])) {

      // Remove any profiles from the list. These will be installed later.
      // @see config_installer_config_import_profile()
      $data['module'] = array_diff_key($data['module'], $this->profiles);
    }
    return $data;
  }

  /**
   * {@inheritdoc}
   */
  public function readMultiple(array $names) {
    $list = [];
    foreach ($names as $name) {
      if ($data = $this
        ->read($name)) {
        $list[$name] = $data;
      }
    }
    return $list;
  }

  /**
   * {@inheritdoc}
   */
  public function write($name, array $data) {
    return $this->baseStorage
      ->write($name, $data);
  }

  /**
   * {@inheritdoc}
   */
  public function delete($name) {
    return $this->baseStorage
      ->delete($name);
  }

  /**
   * {@inheritdoc}
   */
  public function rename($name, $new_name) {
    return $this->baseStorage
      ->rename($name, $new_name);
  }

  /**
   * {@inheritdoc}
   */
  public function encode($data) {
    return $this->baseStorage
      ->encode($data);
  }

  /**
   * {@inheritdoc}
   */
  public function decode($raw) {
    return $this->baseStorage
      ->decode($raw);
  }

  /**
   * {@inheritdoc}
   */
  public function listAll($prefix = '') {
    return $this->baseStorage
      ->listAll($prefix);
  }

  /**
   * {@inheritdoc}
   */
  public function deleteAll($prefix = '') {
    return $this->baseStorage
      ->deleteAll($prefix);
  }

  /**
   * {@inheritdoc}
   */
  public function createCollection($collection) {
    return new static($this->baseStorage
      ->createCollection($collection), $this->profiles);
  }

  /**
   * {@inheritdoc}
   */
  public function getAllCollectionNames() {
    return $this->baseStorage
      ->getAllCollectionNames();
  }

  /**
   * {@inheritdoc}
   */
  public function getCollectionName() {
    return $this->baseStorage
      ->getCollectionName();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
SourceStorage::$baseStorage protected property The configuration storage to wrap.
SourceStorage::$profiles protected property The available install profiles.
SourceStorage::createCollection public function Creates a collection on the storage. Overrides StorageInterface::createCollection
SourceStorage::decode public function Decodes configuration data from the storage-specific format. Overrides StorageInterface::decode
SourceStorage::delete public function Deletes a configuration object from the storage. Overrides StorageInterface::delete
SourceStorage::deleteAll public function Deletes configuration objects whose names start with a given prefix. Overrides StorageInterface::deleteAll
SourceStorage::encode public function Encodes configuration data into the storage-specific format. Overrides StorageInterface::encode
SourceStorage::exists public function Returns whether a configuration object exists. Overrides StorageInterface::exists
SourceStorage::getAllCollectionNames public function Gets the existing collections. Overrides StorageInterface::getAllCollectionNames
SourceStorage::getCollectionName public function Gets the name of the current collection the storage is using. Overrides StorageInterface::getCollectionName
SourceStorage::listAll public function Gets configuration object names starting with a given prefix. Overrides StorageInterface::listAll
SourceStorage::read public function Reads configuration data from the storage. Overrides StorageInterface::read
SourceStorage::readMultiple public function Reads configuration data from the storage. Overrides StorageInterface::readMultiple
SourceStorage::rename public function Renames a configuration object in the storage. Overrides StorageInterface::rename
SourceStorage::write public function Writes configuration data to the storage. Overrides StorageInterface::write
SourceStorage::__construct public function Constructs a SourceStorage object.
StorageInterface::DEFAULT_COLLECTION constant The default collection name.