class PrivateMessageThreadMemberConstraintValidator in Private Message 8
Same name and namespace in other branches
- 8.2 src/Plugin/Validation/Constraint/PrivateMessageThreadMemberConstraintValidator.php \Drupal\private_message\Plugin\Validation\Constraint\PrivateMessageThreadMemberConstraintValidator
Private message thread constraint validator.
Ensures that all members of a private message thread have permission to use the private message thread.
Hierarchy
- class \Drupal\private_message\Plugin\Validation\Constraint\PrivateMessageThreadMemberConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of PrivateMessageThreadMemberConstraintValidator
File
- src/
Plugin/ Validation/ Constraint/ PrivateMessageThreadMemberConstraintValidator.php, line 14
Namespace
Drupal\private_message\Plugin\Validation\ConstraintView source
class PrivateMessageThreadMemberConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
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(),
]);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PrivateMessageThreadMemberConstraintValidator:: |
public | function | Checks if the passed value is valid. |