class SharedEmailUniqueValidator in Shared Email 8.2
Class SharedEmailUniqueValidator.
@package Drupal\sharedemail\Plugin\Validation\Constraint
Hierarchy
- class \Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldValueValidator extends \Symfony\Component\Validator\ConstraintValidator
- class \Drupal\sharedemail\Plugin\Validation\Constraint\SharedEmailUniqueValidator
Expanded class hierarchy of SharedEmailUniqueValidator
File
- src/
Plugin/ Validation/ Constraint/ SharedEmailUniqueValidator.php, line 13
Namespace
Drupal\sharedemail\Plugin\Validation\ConstraintView source
class SharedEmailUniqueValidator extends UniqueFieldValueValidator {
/**
* {@inheritdoc}
*/
public function validate($items, Constraint $constraint) {
if (!($item = $items
->first())) {
return;
}
if (\Drupal::currentUser()
->getAccount()
->hasPermission('create shared email account')) {
$allowed = \Drupal::config('sharedemail.settings')
->get('sharedemail_allowed');
if (empty($allowed) || stripos($allowed, $item->value) !== FALSE) {
return;
}
}
parent::validate($items, $constraint);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SharedEmailUniqueValidator:: |
public | function |
Checks if the passed value is valid. Overrides UniqueFieldValueValidator:: |