public function PrivateMessageThreadMemberConstraintValidator::validate in Private Message 8.2
Same name and namespace in other branches
- 8 src/Plugin/Validation/Constraint/PrivateMessageThreadMemberConstraintValidator.php \Drupal\private_message\Plugin\Validation\Constraint\PrivateMessageThreadMemberConstraintValidator::validate()
File
- src/
Plugin/ Validation/ Constraint/ PrivateMessageThreadMemberConstraintValidator.php, line 19
Class
- PrivateMessageThreadMemberConstraintValidator
- Private message thread constraint validator.
Namespace
Drupal\private_message\Plugin\Validation\ConstraintCode
public function validate($items, Constraint $constraint) {
$users = $items
->referencedEntities();
foreach ($users as $user) {
if (!$user
->hasPermission('use private messaging system')) {
$this->context
->addViolation($constraint->userPrivateMessagePermissionError, [
'%user' => $user
->getDisplayName(),
]);
}
}
}