/** * @param Notification $notification * @param Ticket $ticket * * @return string */ private function getFormattedUserName(Notification $notification, Ticket $ticket) { $author = $notification->getAuthor(); if (is_null($author)) { $reporterId = $ticket->getReporter()->getId(); $user = $this->diamanteUserRepository->get($reporterId); } else { $user = $this->getUserDependingOnType($author); } $name = $this->nameFormatter->format($user); if (empty($name)) { $format = $this->nameFormatter->getNameFormat(); $name = str_replace(array('%first_name%', '%last_name%', '%prefix%', '%middle_name%', '%suffix%'), array($user->getFirstName(), $user->getLastName(), '', '', ''), $format); } $name = preg_replace('/\\s+/', ' ', $name); return trim($name); }
/** * @param Notification $notification * * @return string */ private function getFormattedUserName(Notification $notification) { $user = $notification->getAuthor(); $userId = $this->userService->verifyDiamanteUserExists($user->getEmail()); $user = empty($userId) ? $user : new User($userId, User::TYPE_DIAMANTE); $user = $this->userService->getByUser($user); $format = $this->nameFormatter->getNameFormat(); $name = str_replace(array('%first_name%', '%last_name%', '%prefix%', '%middle_name%', '%suffix%'), array($user->getFirstName(), $user->getLastName(), '', '', ''), $format); return trim($name); }