You are here

trait ConfigSyncActiveStoragesTrait in Configuration Synchronizer 8.2

Provides a utility method for fetching the active storage by collection.

Hierarchy

File

src/ConfigSyncActiveStoragesTrait.php, line 10

Namespace

Drupal\config_sync
View source
trait ConfigSyncActiveStoragesTrait {

  /**
   * The active configuration storages, keyed by collection.
   *
   * @var \Drupal\Core\Config\StorageInterface[]
   */
  protected $activeStorages;

  /**
   * Gets the configuration storage that provides the active configuration.
   *
   * @param string $collection
   *   (optional) The configuration collection. Defaults to the default
   *   collection.
   *
   * @return \Drupal\Core\Config\StorageInterface
   *   The configuration storage that provides the default configuration.
   */
  protected function getActiveStorages($collection = StorageInterface::DEFAULT_COLLECTION) {
    if (!isset($this->activeStorages[$collection])) {
      $this->activeStorages[$collection] = reset($this->activeStorages)
        ->createCollection($collection);
    }
    return $this->activeStorages[$collection];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSyncActiveStoragesTrait::$activeStorages protected property The active configuration storages, keyed by collection.
ConfigSyncActiveStoragesTrait::getActiveStorages protected function Gets the configuration storage that provides the active configuration.