Esempio n. 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);
 }