/** * Tells if the current user is allowed to see the thread * * @param ThreadInterface $thread * * @return boolean */ public function canSeeThread(ThreadInterface $thread) { $currentParticipant = $this->participantProvider->getAuthenticatedParticipant(); if (!$currentParticipant) { return false; } return null !== $thread->getParticipantMetadata($currentParticipant); }
/** * Gets the number of unread messages in the inbox of the current user * * @return int */ public function countInboxNew() { if (!array_key_exists('count_inbox_new', $this->cache)) { $participant = $this->participantProvider->getAuthenticatedParticipant(); $this->cache['count_inbox_new'] = $this->provider->countInboxNewThreads($participant); } return $this->cache['count_inbox_new']; }
/** * 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); } }
public function testCountInbox() { $this->participantProvider->expects($this->once())->method('getAuthenticatedParticipant')->will($this->returnValue($this->participant)); $this->provider->expects($this->once())->method('countInboxNewThreads')->with($this->participant)->will($this->returnValue(3)); $this->assertEquals(3, $this->extension->countInboxNew()); }