/**
  * Indicates whether the constraint is valid
  *
  * @param object     $value
  * @param Constraint $constraint
  */
 public function validate($value, Constraint $constraint)
 {
     $sender = $this->participantProvider->getAuthenticatedParticipant();
     $recipients = $value->getThread()->getOtherParticipants($sender);
     foreach ($recipients as $recipient) {
         if (!$this->authorizer->canSendMessageTo($recipient)) {
             $this->context->addViolation($constraint->message);
             return;
         }
     }
 }
 /**
  * Tells if the current user can send a message to this participant
  *
  * @param ParticipantInterface $participant
  * @return bool
  */
 public function canSendMessage(ParticipantInterface $participant)
 {
     if (!array_key_exists('can_send_' . $participant->getId(), $this->cache)) {
         $this->cache['can_send_' . $participant->getId()] = $this->authorizer->canSendMessageTo($participant);
     }
     return $this->cache['can_send_' . $participant->getId()];
 }
 /**
  * Indicates whether the constraint is valid
  *
  * @param object     $recipient
  * @param Constraint $constraint
  */
 public function validate($recipient, Constraint $constraint)
 {
     if ($recipient && !$this->authorizer->canSendMessageTo($recipient)) {
         $this->context->addViolation($constraint->message);
     }
 }