Пример #1
0
 /**
  * Send notification to clank that user have new emails
  *
  * @param PostFlushEventArgs $args
  */
 public function postFlush(PostFlushEventArgs $args)
 {
     $usersWithNewEmails = [];
     if (!$this->processEmailUsersEntities) {
         return;
     }
     /** @var EmailUser $entity */
     foreach ($this->processEmailUsersEntities as $item) {
         $status = $item['status'];
         $entity = $item['entity'];
         $em = $args->getEntityManager();
         $ownerIds = $this->determineOwners($entity, $em);
         foreach ($ownerIds as $ownerId) {
             if (array_key_exists($ownerId, $usersWithNewEmails) === true) {
                 $new = $usersWithNewEmails[$ownerId]['new'];
                 if ($status === self::ENTITY_STATUS_NEW) {
                     $usersWithNewEmails[$ownerId]['new'] = $new + 1;
                 }
             } else {
                 $usersWithNewEmails[$ownerId] = ['entity' => $entity, 'new' => $status === self::ENTITY_STATUS_NEW ? 1 : 0];
             }
         }
     }
     if ($usersWithNewEmails) {
         $this->processor->send($usersWithNewEmails);
     }
     $this->processEmailUsersEntities = [];
 }
Пример #2
0
 /**
  * Send notification to clank that user have new emails
  */
 public function postFlush()
 {
     $usersWithNewEmails = [];
     if (!$this->processEmailUsersEntities) {
         return;
     }
     /** @var EmailUser $entity */
     foreach ($this->processEmailUsersEntities as $entity) {
         $status = $entity['status'];
         $entity = $entity['entity'];
         if (!$entity->getOwner()) {
             continue;
         }
         $ownerId = $entity->getOwner()->getId();
         if (array_key_exists($ownerId, $usersWithNewEmails) === true) {
             $new = $usersWithNewEmails[$ownerId]['new'];
             if ($status === self::ENTITY_STATUS_NEW) {
                 $usersWithNewEmails[$ownerId]['new'] = $new + 1;
             }
         } else {
             $usersWithNewEmails[$ownerId] = ['entity' => $entity, 'new' => $status === self::ENTITY_STATUS_NEW ? 1 : 0];
         }
     }
     if ($usersWithNewEmails) {
         $this->processor->send($usersWithNewEmails);
     }
     $this->processEmailUsersEntities = [];
 }
 public function testSendFailure()
 {
     $this->topicPublisher->expects($this->never())->method('send');
     $this->processor->send([]);
 }