/** * Indicates whether the constraint is valid * * @param object $recipient * @param Constraint $constraint */ public function isValid($recipient, Constraint $constraint) { if ($recipient === $this->participantProvider->getAuthenticatedParticipant()) { $this->setMessage($constraint->message); return false; } return true; }
/** * Gets the current authenticated user * * @return ParticipantInterface */ protected function getAuthenticatedParticipant() { return $this->participantProvider->getAuthenticatedParticipant(); }
/** * Indicates whether the constraint is valid * * @param object $recipient * @param Constraint $constraint */ public function validate($recipient, Constraint $constraint) { if ($recipient === $this->participantProvider->getAuthenticatedParticipant()) { $this->context->addViolation($constraint->message); } }
/** * Tells whether or not a new message looks like spam * * @param NewThreadMessage $message * @return boolean true if it is spam, false otherwise */ public function isSpam(NewThreadMessage $message) { return $this->akismet->isSpam(array('comment_author' => (string) $this->participantProvider->getAuthenticatedParticipant(), 'comment_content' => $message->getBody())); }