diff --git a/config/schema/password_policy.schema.yml b/config/schema/password_policy.schema.yml index 4b6d6cf..5eb2b35 100644 --- a/config/schema/password_policy.schema.yml +++ b/config/schema/password_policy.schema.yml @@ -1,7 +1,7 @@ # Schema for configuration files of the Password Policy module. password_policy.password_policy.*: - type: mapping + type: config_entity label: 'Password Policy' mapping: id: diff --git a/src/Entity/PasswordPolicy.php b/src/Entity/PasswordPolicy.php index 7e8b029..4580afc 100644 --- a/src/Entity/PasswordPolicy.php +++ b/src/Entity/PasswordPolicy.php @@ -134,4 +134,30 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface return $this->roles; } + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + parent::calculateDependencies(); + + $plugin_manager = $this->getPluginManager(); + + foreach ($this->getConstraints() as $constraint) { + $plugin_definition = $plugin_manager->getDefinition($constraint['id']); + $this->addDependency('module', $plugin_definition['provider']); + } + + return $this; + } + + /** + * Gets the password policy plugin manager. + * + * @return \Drupal\password_policy\PasswordConstraintPluginManager + * The plugin manager. + */ + protected function getPluginManager() { + return \Drupal::service('plugin.manager.password_policy.password_constraint'); + } + }