/** * @param Message $message * @param Ticket $ticket */ private function processWatchers(Message $message, $ticket) { if (!$ticket) { return; } /** @var Message\MessageRecipient $recipient */ foreach ($message->getRecipients() as $recipient) { $email = $recipient->getEmail(); if ($email == $this->configManager->get(self::EMAIL_NOTIFIER_CONFIG_PATH)) { continue; } $user = $this->diamanteUserService->getUserByEmail($email); if (is_null($user)) { $id = $this->diamanteUserService->createDiamanteUser($this->prepareCreateUserCommand($recipient)); $user = new User($id, User::TYPE_DIAMANTE); } $this->watchersService->addWatcher($ticket, $user); } }
/** * @param Message $message * @param Ticket $ticket */ private function processWatchers(Message $message, $ticket) { if (!$ticket) { return; } /** @var Message\MessageRecipient $recipient */ foreach ($message->getRecipients() as $recipient) { $email = $recipient->getEmail(); if ($email == $this->configManager->get(self::EMAIL_NOTIFIER_CONFIG_PATH)) { continue; } $diamanteUser = $this->diamanteUserRepository->findUserByEmail($email); $oroUser = $this->oroUserManager->findUserByEmail($email); if ($oroUser) { $user = new User($oroUser->getId(), User::TYPE_ORO); } elseif ($diamanteUser) { $user = new User($diamanteUser->getId(), User::TYPE_DIAMANTE); } else { $diamanteUser = $this->diamanteUserFactory->create($email, $recipient->getFirstName(), $recipient->getLastName()); $this->diamanteUserRepository->store($diamanteUser); $user = new User($diamanteUser->getId(), User::TYPE_DIAMANTE); } $this->watchersService->addWatcher($ticket, $user); } }