/** * Indicates whether the constraint is valid * * @param object $recipient * @param Constraint $constraint */ public function isValid($recipient, Constraint $constraint) { if ($recipient && !$this->authorizer->canMessageParticipant($recipient)) { $this->setMessage($constraint->message); return false; } return true; }
/** * Marks the thread as undeleted by the current authenticated user * * @param ThreadInterface $thread */ public function markAsUndeleted(ThreadInterface $thread) { if (!$this->authorizer->canDeleteThread($thread)) { throw new AccessDeniedException('You are not allowed to delete this thread'); } $thread->setIsDeletedByParticipant($this->getAuthenticatedParticipant(), false); $this->dispatcher->dispatch(FOSMessageEvents::POST_UNDELETE, new ThreadEvent($thread)); }
/** * 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->canMessageParticipant($recipient)) { $this->context->addViolation($constraint->message); return; } } }
/** * Indicates whether the constraint is valid * * @param object $value * @param Constraint $constraint */ public function isValid($value, Constraint $constraint) { $sender = $this->participantProvider->getAuthenticatedParticipant(); $recipients = $value->getThread()->getOtherParticipants($sender); foreach ($recipients as $recipient) { if (!$this->authorizer->canMessageParticipant($recipient)) { $this->setMessage($constraint->message); return false; } } return true; }
/** * Indicates whether the constraint is valid * * @param object $recipient * @param Constraint $constraint */ public function validate($recipient, Constraint $constraint) { if ($recipient && !$this->authorizer->canMessageParticipant($recipient)) { $this->context->addViolation($constraint->message); } }