You are here

class ConfigProviderInstall in Configuration Provider 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/ConfigProvider/ConfigProviderInstall.php \Drupal\config_provider\Plugin\ConfigProvider\ConfigProviderInstall

Class for providing configuration from an install directory.

Plugin annotation


@ConfigProvider(
  id = \Drupal\config_provider\Plugin\ConfigProvider\ConfigProviderInstall::ID,
  weight = -10,
  label = @Translation("Install"),
  description = @Translation("Configuration to be installed when an extension is installed."),
)

Hierarchy

Expanded class hierarchy of ConfigProviderInstall

File

src/Plugin/ConfigProvider/ConfigProviderInstall.php, line 20

Namespace

Drupal\config_provider\Plugin\ConfigProvider
View source
class ConfigProviderInstall extends ConfigProviderBase {

  /**
   * The configuration provider ID.
   */
  const ID = InstallStorage::CONFIG_INSTALL_DIRECTORY;

  /**
   * {@inheritdoc}
   */
  public function addConfigToCreate(array &$config_to_create, StorageInterface $storage, $collection, $prefix = '', array $profile_storages = []) {

    // The caller will aready have loaded config for install.
  }

  /**
   * {@inheritdoc}
   */
  public function addInstallableConfig(InMemoryStorage $installable_config, array $extensions = []) {
    $storage = $this
      ->getExtensionInstallStorage(static::ID);
    $config_names = $this
      ->listConfig($storage, $extensions);
    $config_to_add = $storage
      ->readMultiple($config_names);
    foreach ($config_to_add as $name => $data) {
      $installable_config
        ->write($name, $data);
    }

    // Get all data from the remaining collections.
    // Gather information about all the supported collections.
    $collection_info = $this->configManager
      ->getConfigCollectionInfo();
    foreach ($collection_info
      ->getCollectionNames() as $collection) {
      $collection_storage = $storage
        ->createCollection($collection);
      $config_names = $this
        ->listConfig($collection_storage, $extensions);
      $config_to_add = $collection_storage
        ->readMultiple($config_names);
      foreach ($config_to_add as $name => $data) {
        $installable_config
          ->writeToCollection($name, $data, $collection);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigProviderBase::$activeStorages protected property The active configuration storages, keyed by collection.
ConfigProviderBase::$configFactory protected property The configuration factory.
ConfigProviderBase::$configManager protected property The configuration manager.
ConfigProviderBase::getActiveStorages protected function Gets the configuration storage that provides the active configuration.
ConfigProviderBase::getDirectory public function Returns the configuration directory. Overrides ConfigProviderInterface::getDirectory
ConfigProviderBase::getEnabledExtensions protected function Gets the list of enabled extensions including both modules and themes.
ConfigProviderBase::getExtensionInstallStorage protected function Gets the storage for a designated configuration provider.
ConfigProviderBase::listConfig protected function Returns a list of all configuration items or those of extensions.
ConfigProviderBase::providesFullConfig public function Indicates whether the configuration items returned by the provider are full as opposed to partials. Overrides ConfigProviderInterface::providesFullConfig
ConfigProviderBase::setActiveStorages public function Injects the active configuration storage. Overrides ConfigProviderInterface::setActiveStorages
ConfigProviderBase::setConfigFactory public function Injects the active configuration storage. Overrides ConfigProviderInterface::setConfigFactory
ConfigProviderBase::setConfigManager public function Injects the active configuration storage. Overrides ConfigProviderInterface::setConfigManager
ConfigProviderBase::validateDependencies protected function Validates an array of config data that contains dependency information.
ConfigProviderInstall::addConfigToCreate public function Adds configuration to be installed. Overrides ConfigProviderInterface::addConfigToCreate
ConfigProviderInstall::addInstallableConfig public function Adds configuration that is available to be installed or updated. Overrides ConfigProviderInterface::addInstallableConfig
ConfigProviderInstall::ID constant The configuration provider ID.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92