public function testTemplateWithEmptyVariables() { $message = '{{item}}' . '++++' . '前面的item里的内容是可更换的'; $variables = array(); $messageResult = StringToolkit::template($message, $variables); $this->assertEquals($message, $messageResult); }
private function sendAuditRefundNotification($order, $pass, $amount, $note) { $course = $this->getCourseService()->getCourse($order['targetId']); if (empty($course)) { return false; } if ($pass) { $message = $this->setting('refund.successNotification', ''); } else { $message = $this->setting('refund.failedNotification', ''); } if (empty($message)) { return false; } $courseUrl = $this->generateUrl('course_show', array('id' => $course['id'])); $variables = array('course' => "<a href='{$courseUrl}'>{$course['title']}</a>", 'amount' => $amount, 'note' => $note); $message = StringToolkit::template($message, $variables); $this->getNotificationService()->notify($order['userId'], 'default', $message); return true; }
public function applyRefundOrder($id, $amount, $reason, $container) { $order = $this->getOrderService()->getOrder($id); if (empty($order)) { throw $this->createServiceException('订单不存在,不嫩申请退款。'); } $refund = $this->getOrderService()->applyRefundOrder($id, $amount, $reason); if ($refund['status'] == 'created') { $this->getCourseService()->lockStudent($order['targetId'], $order['userId']); $setting = $this->getSettingService()->get('refund'); $message = empty($setting) or empty($setting['applyNotification']) ? '' : $setting['applyNotification']; if ($message) { $courseUrl = $container->get('router')->generate('course_show', array('id' => $course['id'])); $variables = array('course' => "<a href='{$courseUrl}'>{$course['title']}</a>"); $message = StringToolkit::template($message, $variables); $this->getNotificationService()->notify($refund['userId'], 'default', $message); } } elseif ($refund['status'] == 'success') { $this->getCourseService()->removeStudent($order['targetId'], $order['userId']); } return $refund; }
public function applyRefundOrder($id, $amount, $reason, $container) { $user = $this->getCurrentUser(); $order = $this->getOrderService()->getOrder($id); if (empty($order)) { throw $this->createServiceException('订单不存在,不能申请退款。'); } $refund = $this->getOrderService()->applyRefundOrder($id, $amount, $reason); if ($refund['status'] == 'created') { $this->getClassroomService()->lockStudent($order['targetId'], $order['userId']); $setting = $this->getSettingService()->get('refund'); $message = empty($setting) || empty($setting['applyNotification']) ? '' : $setting['applyNotification']; $classroom = $this->getClassroomService()->getClassroom($order["targetId"]); $classroomUrl = $container->get('router')->generate('classroom_show', array('id' => $classroom['id'])); if ($message) { $variables = array('item' => "<a href='{$classroomUrl}'>{$classroom['title']}</a>"); $message = StringToolkit::template($message, $variables); $this->getNotificationService()->notify($refund['userId'], 'default', $message); } $adminmessage = '用户' . "{$user['nickname']}" . '申请退款' . "<a href='{$classroomUrl}'>{$classroom['title']}</a>" . "{$classroomSetting['name']},请审核。"; $adminCount = $this->getUserService()->searchUserCount(array('roles' => 'ADMIN')); $admins = $this->getUserService()->searchUsers(array('roles' => 'ADMIN'), array('id', 'DESC'), 0, $adminCount); foreach ($admins as $key => $admin) { $this->getNotificationService()->notify($admin['id'], 'default', $adminmessage); } } elseif ($refund['status'] == 'success') { $this->getClassroomService()->exitClassroom($order['targetId'], $order['userId']); } return $refund; }
public function promoteLinkAction(Request $request) { $user = $this->getCurrentUser(); $message = null; $site = $this->getSettingService()->get('site', array()); $inviteSetting = $this->getSettingService()->get('invite', array()); $urlContent = $this->generateUrl('register', array(), true); $registerUrl = $urlContent . '?inviteCode=' . $user['inviteCode']; if ($inviteSetting['inviteInfomation_template']) { $variables = array('siteName' => $site['name'], 'registerUrl' => $registerUrl); $message = StringToolkit::template($inviteSetting['inviteInfomation_template'], $variables); } return $this->render('TopxiaWebBundle:Coin:promote-link-modal.html.twig', array('code' => $user['inviteCode'], 'inviteInfomation_template' => $message)); }
protected function sendAuditRefundNotification($orderRefundProcessor, $order, $data) { $target = $orderRefundProcessor->getTarget($order['targetId']); if (empty($target)) { return false; } if ($data['result'] == 'pass') { $message = $this->setting('refund.successNotification', ''); } else { $message = $this->setting('refund.failedNotification', ''); } if (empty($message)) { return false; } $targetUrl = $this->generateUrl($order["targetType"] . '_show', array('id' => $order['targetId'])); $variables = array("{$order['targetType']}" => "<a href='{$targetUrl}'>{$target['title']}</a>", "amount" => $data["amount"], "note" => $data["note"]); $message = StringToolkit::template($message, $variables); $this->getNotificationService()->notify($order['userId'], 'default', $message); }