diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 4e83d2e..4bb686a 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -96,7 +96,7 @@ _core_config_info: label: 'Default configuration hash' dependency_resolved: type: boolean - label: 'Signals if a config entity has resolved its dependencies' + label: 'The config has resolved its dependencies' config_object: type: mapping diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index ef49b65..f11effd 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -305,6 +305,7 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names * {@inheritdoc} */ public function getConfigEntitiesToChange($operation, $type, array $names, $dry_run = TRUE) { + // Dependency names as keys, entities as values. $names = $this->getNormalizedNames($type, $names); // Determine the current list of dependent configuration entities and set up // initial values. @@ -399,7 +400,7 @@ public function getConfigCollectionInfo() { * dependencies on the entity. * * @param string $operation - * Can be one of the ConfigManagerInterface constants: REMOVE, UPDATE. + * One of the ConfigManagerInterface operation constants: REMOVE, UPDATE. * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity * The entity to call onDependencyRemoval() on. * @param \Drupal\Core\Config\Entity\ConfigEntityInterface[] $dependent_entities diff --git a/core/lib/Drupal/Core/Config/ConfigManagerDependencyFinderInterface.php b/core/lib/Drupal/Core/Config/ConfigManagerDependencyFinderInterface.php index e4f857e..5c49bde 100644 --- a/core/lib/Drupal/Core/Config/ConfigManagerDependencyFinderInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigManagerDependencyFinderInterface.php @@ -27,11 +27,11 @@ * @param array $names * The specific names to check. If $type equals 'module' or 'theme' then it * should be a list of module names or theme names. In the case of 'config' - * or 'content' it should be a list of configuration dependency names. For - * entity dependencies, the caller can, alternatively, pass the full entity - * object instead of its dependency name. This is particularly useful when - * the dependency gets updated and needs to send the whole entity so that - * the dependant is able to access the fresh data from the entity. + * or 'content' it should be a list of configuration dependency names or, + * alternatively, the full entity objects. This is particularly useful when + * the dependency gets updated and needs to send the whole updated entity to + * the dependency resolver (onDependencyUpdating()), so that the dependant + * is able to access fresh data. * @param bool $dry_run * If set to FALSE the entities returned in the list of updates will be * modified. In order to make the changes the caller needs to save them. If @@ -41,7 +41,7 @@ * An array with the keys: 'update', 'delete' and 'unchanged'. The value of * each is a list of configuration entities that need to have that action * applied when the supplied dependencies are performing an operation such - * as update ir remove. Updates need to be processed before deletes. The + * as update or remove. Updates need to be processed before deletes. The * order of the deletes is significant and must be processed in the returned * order. * diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index b7a31fe..c1d082f 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -110,8 +110,8 @@ * Keys: * - default_config_hash: A hash calculated by the config.installer service * and added during installation. - * - dependency_resolved: Used during dependency resolving process. It's a - * boolean set to TRUE when a dependency has been resolved. + * - dependency_resolved: A boolean set to TRUE when a dependency has been + * resolved during the dependency resolving process. * * @var array */ @@ -357,7 +357,7 @@ public function preSave(EntityStorageInterface $storage) { throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this entity already exists with UUID '{$original->uuid()}'"); } - // Fix any dependencies. + // Fix any dependencies only on entity update. $config_entities = $this->getConfigManager()->getConfigEntitiesToChange(ConfigManagerInterface::UPDATE, 'config', [$this], FALSE); /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $dependent_entity */ foreach ($config_entities['update'] as $dependent_entity) { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependencyResolverInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependencyResolverInterface.php index 45a7bef..1025540 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependencyResolverInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependencyResolverInterface.php @@ -20,9 +20,9 @@ * Informs the entity that entities it depends on will be updated. * * This method allows configuration entities to update themselves when their - * dependencies get updated. For example, if 'format' config entity gets - * disabled, the paired 'editor' config entity can implement this method to - * disable itself. + * dependencies get updated. For example, if 'format' configuration entity + * gets disabled, the paired 'editor' config entity can implement this method + * to disable itself. * * If this method returns TRUE then the entity needs to be re-saved by the * caller for the changes to take effect. Implementations should not save the @@ -33,7 +33,8 @@ * Dependency types are: 'module', 'theme', 'config', 'content'. Each type * is an array keyed by dependency name. If the type is 'module' or 'theme', * the values are module or theme names. In the case of 'config' or - * 'content' each array value is the full dependency entity. + * 'content' each array value is the full dependency entity. Implementations + * can retrieve the dependencies updated data in passed entities. * * @return bool * TRUE if the entity has changed, FALSE if not. @@ -60,6 +61,7 @@ public function onDependencyUpdating(array $dependencies); * * @see \Drupal\Core\Config\ConfigManager::getConfigEntitiesToChange() * @see \Drupal\Core\Config\ConfigManager::callOnDependencyResolver() + * @see \Drupal\Core\Config\ConfigEntityBase::preSave() * * @todo Move this method in \Drupal\Core\Config\Entity\ConfigEntityInterface * in Drupal 9.0.x. @@ -67,9 +69,9 @@ public function onDependencyUpdating(array $dependencies); public function setDependencyResolved($resolved); /** - * Returns if an dependency entity has been resolved. + * Informs that a dependency entity has been resolved. * - * Tells the configuration dependency system that a config entity has been + * Informs the configuration dependency system that a config entity has been * just resolved. * * @return bool diff --git a/core/modules/editor/src/Entity/Editor.php b/core/modules/editor/src/Entity/Editor.php index 4777280..b200393 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -193,6 +193,8 @@ public function onDependencyUpdating(array $dependencies) { if (!empty($format = $dependencies['config'][$this->getFilterFormat()->getConfigDependencyName()])) { if (($status = $format->status()) !== $format->original->status()) { + // If the status of the text format has been changed, synchronize the + // status of the editor. $this->setStatus($status); $changed = TRUE; } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index 44b2d62..1272e78 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -135,7 +135,7 @@ protected function setUp() { $container->set('config.typed', $this->typedConfigManager); $config_manager = $this->getMock(ConfigManagerDependencyFinderInterface::class); $config_manager->method('getConfigEntitiesToChange') - ->will($this->returnValue(['update' => []]));; + ->will($this->returnValue(['update' => [], 'delete' => [], 'unchanged' => []])); $container->set('config.manager', $config_manager); \Drupal::setContainer($container);