You are here

interface StorageInterface in Zircon Profile 8

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

Defines an interface for configuration storage.

Classes implementing this interface allow reading and writing configuration data from and to the storage.

Hierarchy

Expanded class hierarchy of StorageInterface

All classes that implement StorageInterface

22 files declare their use of StorageInterface
CacheabilityMetadataConfigOverride.php in core/modules/config/tests/config_override_integration_test/src/CacheabilityMetadataConfigOverride.php
Contains \Drupal\config_override_integration_test\CacheabilityMetadataConfigOverride.
ConfigAfterInstallerTestBase.php in core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php
Contains \Drupal\system\Tests\Installer\ConfigAfterInstallerTestBase.
ConfigController.php in core/modules/config/src/Controller/ConfigController.php
Contains \Drupal\config\Controller\ConfigController.
ConfigImportForm.php in core/modules/config/src/Form/ConfigImportForm.php
Contains \Drupal\config\Form\ConfigImportForm.
ConfigInstallWebTest.php in core/modules/config/src/Tests/ConfigInstallWebTest.php
Contains \Drupal\config\Tests\ConfigInstallWebTest.

... See full list

File

core/lib/Drupal/Core/Config/StorageInterface.php, line 16
Contains \Drupal\Core\Config\StorageInterface.

Namespace

Drupal\Core\Config
View source
interface StorageInterface {

  /**
   * The default collection name.
   */
  const DEFAULT_COLLECTION = '';

  /**
   * Returns whether a configuration object exists.
   *
   * @param string $name
   *   The name of a configuration object to test.
   *
   * @return bool
   *   TRUE if the configuration object exists, FALSE otherwise.
   */
  public function exists($name);

  /**
   * Reads configuration data from the storage.
   *
   * @param string $name
   *   The name of a configuration object to load.
   *
   * @return array|bool
   *   The configuration data stored for the configuration object name. If no
   *   configuration data exists for the given name, FALSE is returned.
   */
  public function read($name);

  /**
   * Reads configuration data from the storage.
   *
   * @param array $names
   *   List of names of the configuration objects to load.
   *
   * @return array
   *   A list of the configuration data stored for the configuration object name
   *   that could be loaded for the passed list of names.
   */
  public function readMultiple(array $names);

  /**
   * Writes configuration data to the storage.
   *
   * @param string $name
   *   The name of a configuration object to save.
   * @param array $data
   *   The configuration data to write.
   *
   * @return bool
   *   TRUE on success, FALSE in case of an error.
   *
   * @throws \Drupal\Core\Config\StorageException
   *   If the back-end storage does not exist and cannot be created.
   */
  public function write($name, array $data);

  /**
   * Deletes a configuration object from the storage.
   *
   * @param string $name
   *   The name of a configuration object to delete.
   *
   * @return bool
   *   TRUE on success, FALSE otherwise.
   */
  public function delete($name);

  /**
   * Renames a configuration object in the storage.
   *
   * @param string $name
   *   The name of a configuration object to rename.
   * @param string $new_name
   *   The new name of a configuration object.
   *
   * @return bool
   *   TRUE on success, FALSE otherwise.
   */
  public function rename($name, $new_name);

  /**
   * Encodes configuration data into the storage-specific format.
   *
   * @param array $data
   *   The configuration data to encode.
   *
   * @return string
   *   The encoded configuration data.
   *
   * This is a publicly accessible static method to allow for alternative
   * usages in data conversion scripts and also tests.
   */
  public function encode($data);

  /**
   * Decodes configuration data from the storage-specific format.
   *
   * @param string $raw
   *   The raw configuration data string to decode.
   *
   * @return array
   *   The decoded configuration data as an associative array.
   *
   * This is a publicly accessible static method to allow for alternative
   * usages in data conversion scripts and also tests.
   */
  public function decode($raw);

  /**
   * Gets configuration object names starting with a given prefix.
   *
   * Given the following configuration objects:
   * - node.type.article
   * - node.type.page
   *
   * Passing the prefix 'node.type.' will return an array containing the above
   * names.
   *
   * @param string $prefix
   *   (optional) The prefix to search for. If omitted, all configuration object
   *   names that exist are returned.
   *
   * @return array
   *   An array containing matching configuration object names.
   */
  public function listAll($prefix = '');

  /**
   * Deletes configuration objects whose names start with a given prefix.
   *
   * Given the following configuration object names:
   * - node.type.article
   * - node.type.page
   *
   * Passing the prefix 'node.type.' will delete the above configuration
   * objects.
   *
   * @param string $prefix
   *   (optional) The prefix to search for. If omitted, all configuration
   *   objects that exist will be deleted.
   *
   * @return bool
   *   TRUE on success, FALSE otherwise.
   */
  public function deleteAll($prefix = '');

  /**
   * Creates a collection on the storage.
   *
   * A configuration storage can contain multiple sets of configuration objects
   * in partitioned collections. The collection name identifies the current
   * collection used.
   *
   * Implementations of this method must provide a new instance to avoid side
   * effects caused by the fact that Config objects have their storage injected.
   *
   * @param string $collection
   *   The collection name. Valid collection names conform to the following
   *   regex [a-zA-Z_.]. A storage does not need to have a collection set.
   *   However, if a collection is set, then storage should use it to store
   *   configuration in a way that allows retrieval of configuration for a
   *   particular collection.
   *
   * @return \Drupal\Core\Config\StorageInterface
   *   A new instance of the storage backend with the collection set.
   */
  public function createCollection($collection);

  /**
   * Gets the existing collections.
   *
   * A configuration storage can contain multiple sets of configuration objects
   * in partitioned collections. The collection key name identifies the current
   * collection used.
   *
   * @return array
   *   An array of existing collection names.
   */
  public function getAllCollectionNames();

  /**
   * Gets the name of the current collection the storage is using.
   *
   * @return string
   *   The current collection name.
   */
  public function getCollectionName();

}

Members

Namesort descending Modifiers Type Description Overrides
StorageInterface::createCollection public function Creates a collection on the storage. 5
StorageInterface::decode public function Decodes configuration data from the storage-specific format. 5
StorageInterface::DEFAULT_COLLECTION constant The default collection name.
StorageInterface::delete public function Deletes a configuration object from the storage. 5
StorageInterface::deleteAll public function Deletes configuration objects whose names start with a given prefix. 5
StorageInterface::encode public function Encodes configuration data into the storage-specific format. 5
StorageInterface::exists public function Returns whether a configuration object exists. 5
StorageInterface::getAllCollectionNames public function Gets the existing collections. 5
StorageInterface::getCollectionName public function Gets the name of the current collection the storage is using. 5
StorageInterface::listAll public function Gets configuration object names starting with a given prefix. 5
StorageInterface::read public function Reads configuration data from the storage. 5
StorageInterface::readMultiple public function Reads configuration data from the storage. 5
StorageInterface::rename public function Renames a configuration object in the storage. 5
StorageInterface::write public function Writes configuration data to the storage. 5