public function SharedEmailUniqueValidator::validate in Shared Email 8.2
Overrides UniqueFieldValueValidator::validate
File
- src/
Plugin/ Validation/ Constraint/ SharedEmailUniqueValidator.php, line 18
Class
- SharedEmailUniqueValidator
- Class SharedEmailUniqueValidator.
Namespace
Drupal\sharedemail\Plugin\Validation\ConstraintCode
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);
}