diff --git a/core/core.services.yml b/core/core.services.yml index 7d9e831..39a6d6b 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -100,7 +100,7 @@ services: class: Drupal\Core\Config\InstallStorage config.typed: class: Drupal\Core\Config\TypedConfigManager - arguments: ['@config.storage', '@config.storage.schema'] + arguments: ['@config.storage', '@config.storage.schema', '@module_handler'] database: class: Drupal\Core\Database\Connection factory_class: Drupal\Core\Database\Database diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 71aa0bc..1112ed7 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -12,6 +12,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; use Drupal\Core\Config\TypedConfigManagerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; /** * Manages config type plugins. @@ -40,6 +41,18 @@ class TypedConfigManager extends PluginManagerBase implements TypedConfigManager protected $definitions; /** + * The module handler to invoke the alter hook. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * @var string + */ + protected $alterHook; + + /** * Creates a new typed configuration manager. * * @param \Drupal\Core\Config\StorageInterface $configStorage @@ -47,12 +60,26 @@ class TypedConfigManager extends PluginManagerBase implements TypedConfigManager * @param \Drupal\Core\Config\StorageInterface $schemaStorage * The storage controller object to use for reading schema data */ - public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage) { + public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, ModuleHandlerInterface $module_handler) { + $this->alterInfo($module_handler, 'config_typed_info'); $this->configStorage = $configStorage; $this->schemaStorage = $schemaStorage; } /** + * Initializes the alter hook. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler to invoke the alter hook with. + * @param string $alter_hook + * Name of the alter hook. + */ + protected function alterInfo(ModuleHandlerInterface $module_handler, $alter_hook) { + $this->moduleHandler = $module_handler; + $this->alterHook = $alter_hook; + } + + /** * Gets typed configuration data. * * @param string $name @@ -161,14 +188,18 @@ public function getDefinition($base_plugin_id) { */ public function getDefinitions() { if (!isset($this->definitions)) { - $this->definitions = array(); + $definitions = array(); foreach ($this->schemaStorage->listAll() as $name) { if ($schema = $this->schemaStorage->read($name)) { foreach ($schema as $type => $definition) { - $this->definitions[$type] = $definition; + $definitions[$type] = $definition; } } } + if ($this->alterHook) { + $this->moduleHandler->alter($this->alterHook, $definitions); + } + $this->definitions = $definitions; } return $this->definitions; }