Loading src/Entity/PasswordPolicy.php +40 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\password_policy\Entity; use Drupal\Core\Plugin\DefaultLazyPluginCollection; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\password_policy\PasswordPolicyInterface; Loading Loading @@ -99,6 +100,13 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface */ protected $roles = []; /** * The constraints as a collection. * * @var \Drupal\Core\Plugin\DefaultLazyPluginCollection */ protected $constraintsCollection; /** * {@inheritdoc} */ Loading Loading @@ -146,6 +154,20 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface return $this->password_reset; } /** * Get the plugin collections used by this entity. * * @return Drupal\Core\Plugin\DefaultLazyPluginCollection * An array of plugin collections, keyed by the property name they use to * store their configuration. */ public function getConstraintsCollection() { if (!isset($this->constraintsCollection)) { $this->constraintsCollection = new DefaultLazyPluginCollection(\Drupal::service('plugin.manager.password_policy.password_constraint'), $this->getConstraints()); } return $this->constraintsCollection; } /** * Return the password reset email value from the policy. * Loading Loading @@ -176,4 +198,22 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface return $this->roles; } /** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $constraints_collection = $this->getConstraintsCollection(); if (empty($constraints_collection)) { return $this; } $constraint_plugin_ids = $constraints_collection->getInstanceIds(); foreach ($constraint_plugin_ids as $constraint_plugin_id) { $constraint_plugin = $constraints_collection->get($constraint_plugin_id); $constraint_plugin_dependencies = $this->getPluginDependencies($constraint_plugin); $this->addDependencies($constraint_plugin_dependencies); } return $this; } } Loading
src/Entity/PasswordPolicy.php +40 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\password_policy\Entity; use Drupal\Core\Plugin\DefaultLazyPluginCollection; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\password_policy\PasswordPolicyInterface; Loading Loading @@ -99,6 +100,13 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface */ protected $roles = []; /** * The constraints as a collection. * * @var \Drupal\Core\Plugin\DefaultLazyPluginCollection */ protected $constraintsCollection; /** * {@inheritdoc} */ Loading Loading @@ -146,6 +154,20 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface return $this->password_reset; } /** * Get the plugin collections used by this entity. * * @return Drupal\Core\Plugin\DefaultLazyPluginCollection * An array of plugin collections, keyed by the property name they use to * store their configuration. */ public function getConstraintsCollection() { if (!isset($this->constraintsCollection)) { $this->constraintsCollection = new DefaultLazyPluginCollection(\Drupal::service('plugin.manager.password_policy.password_constraint'), $this->getConstraints()); } return $this->constraintsCollection; } /** * Return the password reset email value from the policy. * Loading Loading @@ -176,4 +198,22 @@ class PasswordPolicy extends ConfigEntityBase implements PasswordPolicyInterface return $this->roles; } /** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $constraints_collection = $this->getConstraintsCollection(); if (empty($constraints_collection)) { return $this; } $constraint_plugin_ids = $constraints_collection->getInstanceIds(); foreach ($constraint_plugin_ids as $constraint_plugin_id) { $constraint_plugin = $constraints_collection->get($constraint_plugin_id); $constraint_plugin_dependencies = $this->getPluginDependencies($constraint_plugin); $this->addDependencies($constraint_plugin_dependencies); } return $this; } }