コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Gets the current authenticated user
  *
  * @return ParticipantInterface
  */
 protected function getAuthenticatedParticipant()
 {
     return $this->participantProvider->getAuthenticatedParticipant();
 }
コード例 #3
0
 /**
  * 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);
     }
 }
コード例 #4
0
 /**
  * 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()));
 }