コード例 #1
0
 /**
  * @param EmailUser     $entity
  * @param EntityManager $em
  *
  * @return array
  */
 protected function determineOwners(EmailUser $entity, EntityManager $em)
 {
     $ownerIds = [];
     if ($entity->getOwner() !== null) {
         $ownerIds[] = $entity->getOwner()->getId();
     } else {
         $mailbox = $entity->getMailboxOwner();
         if ($mailbox !== null) {
             $authorizedUsers = $mailbox->getAuthorizedUsers();
             foreach ($authorizedUsers as $user) {
                 $ownerIds[] = $user->getId();
             }
             $authorizedRoles = $mailbox->getAuthorizedRoles();
             foreach ($authorizedRoles as $role) {
                 $users = $em->getRepository('OroUserBundle:Role')->getUserQueryBuilder($role)->getQuery()->getResult();
                 foreach ($users as $user) {
                     $ownerIds[] = $user->getId();
                 }
             }
         }
     }
     return array_unique($ownerIds);
 }
コード例 #2
0
ファイル: EmailUserTest.php プロジェクト: woei66/platform
 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());
 }