You are here

class ConfigCollectionInfo in Zircon Profile 8.0

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

Gets information on all the possible configuration collections.

Hierarchy

Expanded class hierarchy of ConfigCollectionInfo

2 files declare their use of ConfigCollectionInfo
EventSubscriber.php in core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php
Contains \Drupal\config_collection_install_test\EventSubscriber.
LanguageConfigFactoryOverride.php in core/modules/language/src/Config/LanguageConfigFactoryOverride.php
Contains \Drupal\language\Config\LanguageConfigFactoryOverride.

File

core/lib/Drupal/Core/Config/ConfigCollectionInfo.php, line 15
Contains \Drupal\Core\Config\ConfigCollectionInfo.

Namespace

Drupal\Core\Config
View source
class ConfigCollectionInfo extends Event {

  /**
   * Configuration collection information keyed by collection name.
   *
   * The value is either the configuration factory override that is responsible
   * for the collection or null if there is not one.
   *
   * @var array
   */
  protected $collections = array();

  /**
   * Adds a collection to the list of possible collections.
   *
   * @param string $collection
   *   Collection name to add.
   * @param \Drupal\Core\Config\ConfigFactoryOverrideInterface
   *   (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
   */
  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;
  }

  /**
   * Gets the list of possible collection names.
   *
   * @param bool $include_default
   *   (Optional) Include the default collection. Defaults to TRUE.
   *
   * @return array
   *   The list of possible collection names.
   */
  public function getCollectionNames($include_default = TRUE) {
    $collection_names = array_keys($this->collections);
    sort($collection_names);
    if ($include_default) {
      array_unshift($collection_names, StorageInterface::DEFAULT_COLLECTION);
    }
    return $collection_names;
  }

  /**
   * Gets the config factory override service responsible for the collection.
   *
   * @param string $collection
   *   The configuration collection.
   *
   * @return \Drupal\Core\Config\ConfigFactoryOverrideInterface|NULL
   *   The override service responsible for the collection if one exists. NULL
   *   if not.
   */
  public function getOverrideService($collection) {
    return isset($this->collections[$collection]) ? $this->collections[$collection] : NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigCollectionInfo::$collections protected property Configuration collection information keyed by collection name.
ConfigCollectionInfo::addCollection public function Adds a collection to the list of possible collections.
ConfigCollectionInfo::getCollectionNames public function Gets the list of possible collection names.
ConfigCollectionInfo::getOverrideService public function Gets the config factory override service responsible for the collection.
Event::$dispatcher private property
Event::$name private property
Event::$propagationStopped private property
Event::getDispatcher Deprecated public function Returns the EventDispatcher that dispatches this Event.
Event::getName Deprecated public function Gets the event's name.
Event::isPropagationStopped public function Returns whether further event listeners should be triggered.
Event::setDispatcher Deprecated public function Stores the EventDispatcher that dispatches this Event.
Event::setName Deprecated public function Sets the event's name property.
Event::stopPropagation public function Stops the propagation of the event to further event listeners.