function ConfigCollectionInfo::addCollection

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigCollectionInfo.php \Drupal\Core\Config\ConfigCollectionInfo::addCollection()
  2. 8.9.x core/lib/Drupal/Core/Config/ConfigCollectionInfo.php \Drupal\Core\Config\ConfigCollectionInfo::addCollection()
  3. 11.x core/lib/Drupal/Core/Config/ConfigCollectionInfo.php \Drupal\Core\Config\ConfigCollectionInfo::addCollection()

Adds a collection to the list of possible collections.

Parameters

string $collection: Collection name to add.

\Drupal\Core\Config\ConfigFactoryOverrideInterface $override_service: (optional) The configuration factory override service responsible for the collection.

Throws

\InvalidArgumentException Exception thrown if $collection is equal to \Drupal\Core\Config\StorageInterface::DEFAULT_COLLECTION.

File

core/lib/Drupal/Core/Config/ConfigCollectionInfo.php, line 35

Class

ConfigCollectionInfo
Gets information on all the possible configuration collections.

Namespace

Drupal\Core\Config

Code

public function addCollection($collection, ?ConfigFactoryOverrideInterface $override_service = NULL) {
    if ($collection == StorageInterface::DEFAULT_COLLECTION) {
        throw new \InvalidArgumentException('Can not add the default collection to the ConfigCollectionInfo object');
    }
    $this->collections[$collection] = $override_service;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.