/** * Set email as seen * * @param EmailUser $entity */ public function setEmailUserSeen(EmailUser $entity) { if (!$entity->isSeen()) { $entity->setSeen(true); $this->em->flush(); } }
/** * Toggle EmailUser thread seen * * @param EmailUser $entity */ public function toggleEmailUserSeen(EmailUser $entity) { $seen = !$entity->isSeen(); $this->setEmailUserSeen($entity, $seen); $this->em->persist($entity); if ($entity->getEmail()->getThread() && $entity->getOwner()) { $threadedEmailUserBuilder = $this->em->getRepository('OroEmailBundle:EmailUser')->getEmailUserByThreadId([$entity->getEmail()->getThread()->getId()], $entity->getOwner()); $threadedEmailUserList = $threadedEmailUserBuilder->getQuery()->getResult(); foreach ($threadedEmailUserList as $threadedEmailUser) { $this->setEmailUserSeen($threadedEmailUser, $seen); $this->em->persist($threadedEmailUser); } } $this->em->flush(); }
public function testGetterSetter() { $emailUser = new EmailUser(); $email = new Email(); $owner = new User(); $organization = new Organization(); $folder = new EmailFolder(); $receivedAt = new DateTime('now'); $emailUser->setEmail($email); $emailUser->setOrganization($organization); $emailUser->addFolder($folder); $emailUser->setSeen(true); $emailUser->setOwner($owner); $emailUser->setReceivedAt($receivedAt); $this->assertEquals($email, $emailUser->getEmail()); $this->assertEquals($organization, $emailUser->getOrganization()); $this->assertEquals($folder, $emailUser->getFolders()->first()); $this->assertEquals(true, $emailUser->isSeen()); $this->assertEquals($owner, $emailUser->getOwner()); $this->assertEquals($receivedAt, $emailUser->getReceivedAt()); $this->assertNull($emailUser->getCreatedAt()); }