当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceKernel::instance方法代码示例

本文整理汇总了PHP中Topxia\Service\Common\ServiceKernel::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceKernel::instance方法的具体用法?PHP ServiceKernel::instance怎么用?PHP ServiceKernel::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topxia\Service\Common\ServiceKernel的用法示例。


在下文中一共展示了ServiceKernel::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lessonHomeworkListAction

 public function lessonHomeworkListAction(Request $request, $courseId, $lessonId)
 {
     $course = ServiceKernel::instance()->createService('Course.CourseService')->getCourse($courseId);
     $lesson = ServiceKernel::instance()->createService('Course.CourseService')->getCourseLesson($courseId, $lessonId);
     $homeworkService = $this->getHomeworkService();
     $homework = $homeworkService->findHomeworkByLessonId($lessonId);
     $homeworkMemberService = $this->getHomeworkMemberService();
     $homework_members = $homeworkMemberService->findHomeworkMembersByLessonId($lessonId);
     $conditions = array();
     $conditions['lesson_id'] = $lesson['id'];
     $orderBy = array();
     $orderBy[] = 'create_at';
     $orderBy[] = 'DESC';
     $count = $homeworkMemberService->searchHomeworkMembersCount($conditions);
     $page_size = 20;
     $paginator = new Paginator($request, $count, $page_size);
     $start = $paginator->getOffsetCount();
     $limit = $paginator->getPerPageCount();
     $homework_members = $homeworkMemberService->searchHomeworkMembers($conditions, $orderBy, $start, $limit);
     $homework_members = $this->addUser($homework_members);
     $tpl = 'HomeworkBundle:Homework:lesson-homework-list.html.twig';
     $assignBox = array();
     $assignBox['course'] = $course;
     $assignBox['lesson'] = $lesson;
     $assignBox['homework'] = $homework;
     $assignBox['homework_members'] = $homework_members;
     $assignBox['paginator'] = $paginator;
     return $this->render($tpl, $assignBox);
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:29,代码来源:HomeworkController.php

示例2: fillUserAttr

 public function fillUserAttr($userId, $userInfo)
 {
     $user = ServiceKernel::instance()->createService('User.UserService')->getUser($userId);
     if (!empty($userInfo['avatar'])) {
         $curl = curl_init($userInfo['avatar']);
         $smallName = date("Ymdhis") . "_small.jpg";
         $mediumName = date("Ymdhis") . "_medium.jpg";
         $largeName = date("Ymdhis") . "_large.jpg";
         $smallPath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $smallName;
         $mediumPath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $mediumName;
         $largePath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $largeName;
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
         $imageData = curl_exec($curl);
         curl_close($curl);
         $tp = @fopen($smallPath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $tp = @fopen($mediumPath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $tp = @fopen($largePath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($smallPath));
         $fields[] = array('type' => 'large', 'id' => $file['id']);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($mediumPath));
         $fields[] = array('type' => 'medium', 'id' => $file['id']);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($largePath));
         $fields[] = array('type' => 'small', 'id' => $file['id']);
         $user = ServiceKernel::instance()->createService('User.UserService')->changeAvatar($userId, $fields);
     }
     return $user;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:34,代码来源:UserUtil.php

示例3: createOrder

 public function createOrder($info)
 {
     $connection = ServiceKernel::instance()->getConnection();
     try {
         $connection->beginTransaction();
         $user = $this->getCurrentUser();
         if (!$user->isLogin()) {
             throw $this->createServiceException('用户未登录,不能创建订单');
         }
         if (!ArrayToolkit::requireds($info, array('targetId', 'payment'))) {
             throw $this->createServiceException('订单数据缺失,创建课程订单失败。');
         }
         // 获得锁
         $user = $this->getUserService()->getUser($user['id'], true);
         if ($this->getClassroomService()->isClassroomStudent($info['targetId'], $user['id'])) {
             throw $this->createServiceException('已经是班级学员,创建订单失败。');
         }
         $classroom = $this->getClassroomService()->getClassroom($info['targetId']);
         if (empty($classroom)) {
             throw $this->createServiceException('班级不存在,创建课程订单失败。');
         }
         if ($classroom['private'] == 1) {
             throw $this->createServiceException('该班级是封闭班级,学员不能自行加入!');
         }
         $order = array();
         $order['userId'] = $user['id'];
         $order['title'] = "购买班级《{$classroom['title']}》";
         $order['targetType'] = 'classroom';
         $order['targetId'] = $classroom['id'];
         $order['payment'] = $info['payment'];
         $order['amount'] = empty($info['amount']) ? 0 : $info['amount'];
         $order['priceType'] = $info['priceType'];
         $order['totalPrice'] = $info["totalPrice"];
         $order['coinRate'] = $info['coinRate'];
         $order['coinAmount'] = $info['coinAmount'];
         $order['snPrefix'] = 'CR';
         if (!empty($info['note'])) {
             $order['data'] = array('note' => $info['note']);
         }
         if (!empty($info['coupon'])) {
             $order['coupon'] = $info['coupon'];
             $order['couponDiscount'] = $info['couponDiscount'];
         }
         $order = $this->getOrderService()->createOrder($order);
         if (empty($order)) {
             throw $this->createServiceException('创建订单失败!');
         }
         // 免费班级,就直接将订单置为已购买
         if (intval($order['amount'] * 100) == 0 && intval($order['coinAmount'] * 100) == 0 && empty($order['coupon'])) {
             list($success, $order) = $this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
             $info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']);
             $this->getClassroomService()->becomeStudent($order['targetId'], $order['userId'], $info);
         }
         $connection->commit();
         return $order;
     } catch (\Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:60,代码来源:ClassroomOrderServiceImpl.php

示例4: processOrder

 public function processOrder($payData, $lock = true)
 {
     $connection = ServiceKernel::instance()->getConnection();
     try {
         if ($lock) {
             $connection->beginTransaction();
         }
         list($success, $order) = $this->getOrderService()->payOrder($payData);
         if ($order["coupon"]) {
             $this->useCoupon($order);
         }
         $processor = OrderProcessorFactory::create($order["targetType"]);
         if ($order['status'] == 'paid' && $processor) {
             $processor->doPaySuccess($success, $order);
         }
         if ($lock) {
             $connection->commit();
         }
         return array($success, $order);
     } catch (\Exception $e) {
         if ($lock) {
             $connection->rollback();
         }
         throw $e;
     }
     return array(false, array());
 }
开发者ID:piaolankeke,项目名称:EduSoho,代码行数:27,代码来源:PayCenterServiceImpl.php

示例5: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST && $request->getMethod() == 'POST') {
         if (stripos($request->getPathInfo(), '/mapi') === 0) {
             return;
         }
         if (stripos($request->getPathInfo(), '/hls') === 0) {
             return;
         }
         $whiteList = array('/coin/pay/return/alipay', '/coin/pay/notify/alipay', '/coin/pay/notify/wxpay', '/pay/center/pay/alipay/return', '/pay/center/pay/wxpay/notify', '/pay/center/pay/alipay/notify', '/live/verify', '/course/order/pay/alipay/notify', '/vip/pay_notify/alipay', '/uploadfile/upload', '/uploadfile/cloud_convertcallback', '/uploadfile/cloud_convertcallback2', '/uploadfile/cloud_convertcallback3', '/uploadfile/cloud_convertheadleadercallback', '/disk/upload', '/file/upload', '/editor/upload', '/disk/convert/callback', '/partner/phpwind/api/notify', '/partner/discuz/api/notify', '/live/auth', '/edu_cloud/sms_callback');
         if (in_array($request->getPathInfo(), $whiteList)) {
             return;
         }
         if ($request->isXmlHttpRequest()) {
             $token = $request->headers->get('X-CSRF-Token');
         } else {
             $token = $request->request->get('_csrf_token', '');
         }
         $request->request->remove('_csrf_token');
         $expectedToken = $this->container->get('form.csrf_provider')->generateCsrfToken('site');
         if ($token != $expectedToken) {
             // @todo 需要区分ajax的response
             if ($request->getPathInfo() == '/admin') {
                 $token = $request->request->get('token');
                 $result = ServiceKernel::instance()->createService('CloudPlatform.AppService')->repairProblem($token);
                 $this->container->set('Topxia.RepairProblem', $result);
             } else {
                 $response = $this->container->get('templating')->renderResponse('TopxiaWebBundle:Default:message.html.twig', array('type' => 'error', 'message' => '页面已过期,请重新提交数据!', 'goto' => '', 'duration' => 0));
                 $event->setResponse($response);
             }
         }
     }
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:34,代码来源:KernelRequestListener.php

示例6: parseItem

 public function parseItem($url)
 {
     $parsers = array('YoukuVideo', 'QQVideo', 'NeteaseOpenCourse', 'TudouVideo');
     $kernel = ServiceKernel::instance();
     $extras = array();
     if ($kernel->hasParameter('media_parser')) {
         $extras = $kernel->getParameter('media_parser');
     }
     if ($extras['item']) {
         $extrasParsers = $extras['item'];
         foreach ($extrasParsers as $extrasParser) {
             $class = $extrasParser['class'];
             $parser = new $class();
             if (!$parser->detect($url)) {
                 continue;
             }
             return $parser->parse($url);
         }
     }
     foreach ($parsers as $parserName) {
         $class = __NAMESPACE__ . "\\ItemParser\\{$parserName}ItemParser";
         $parser = new $class();
         if (!$parser->detect($url)) {
             continue;
         }
         return $parser->parse($url);
     }
     throw $this->createParserNotFoundException();
 }
开发者ID:fujianguo,项目名称:EduSoho,代码行数:29,代码来源:ParserProxy.php

示例7: initAlipayConfig

 protected static function initAlipayConfig($name)
 {
     $payment = ServiceKernel::instance()->createService('System.SettingService')->get('payment', array());
     $alipay_config = array();
     $alipay_config['seller_email'] = empty($payment['alipay_account']) ? '' : $payment['alipay_account'];
     $alipay_config['partner'] = empty($payment['alipay_key']) ? '' : $payment['alipay_key'];
     //安全检验码,以数字和字母组成的32位字符
     //如果签名方式设置为“MD5”时,请设置该参数
     $alipay_config['key'] = empty($payment['alipay_secret']) ? '' : $payment['alipay_secret'];
     //商户的私钥(后缀是.pen)文件相对路径
     //如果签名方式设置为“0001”时,请设置该参数
     // $alipay_config['private_key_path'] = 'key/rsa_private_key.pem';
     // //支付宝公钥(后缀是.pen)文件相对路径
     // //如果签名方式设置为“0001”时,请设置该参数
     // $alipay_config['ali_public_key_path'] = 'key/alipay_public_key.pem';
     //签名方式 不需修改
     $alipay_config['sign_type'] = 'MD5';
     //字符编码格式 目前支持 gbk 或 utf-8
     $alipay_config['input_charset'] = 'utf-8';
     //ca证书路径地址,用于curl中ssl校验
     //请保证cacert.pem文件在当前文件夹目录中
     $alipay_config['cacert'] = getcwd() . '\\cacert.pem';
     //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
     $alipay_config['transport'] = 'http';
     return $alipay_config;
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:26,代码来源:MobileAlipayConfig.php

示例8: convert

 public function convert($id)
 {
     $Classroom = ServiceKernel::instance()->createService('Classroom:Classroom.ClassroomService')->getClassroom($id);
     if (empty($Classroom)) {
         throw new \Exception('user not found');
     }
     return $Classroom;
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:8,代码来源:ClassroomConvert.php

示例9: createClient

 public static function createClient()
 {
     $setting = ServiceKernel::instance()->createService('System.SettingService')->get('storage', array());
     $class = __NAMESPACE__ . '\\EdusohoLiveClient';
     $arguments = array('apiServer' => $setting['cloud_api_server'], 'accessKey' => $setting['cloud_access_key'], 'secretKey' => $setting['cloud_secret_key']);
     $client = new $class($arguments);
     return $client;
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:8,代码来源:LiveClientFactory.php

示例10: getSchoolApps

 private function getSchoolApps()
 {
     $mobile = ServiceKernel::instance()->createService('System.SettingService')->get('mobile');
     $site = ServiceKernel::instance()->createService('System.SettingService')->get('site');
     $apps[1] = array('id' => "1", 'code' => 'announcement', 'name' => $site['name'], 'title' => $site['slogan'], 'about' => $mobile['about'], 'avatar' => $mobile['logo'], 'callback' => '/mobileschools/announcements');
     $apps[2] = array('id' => "2", 'code' => 'news', 'name' => '资讯', 'title' => '网校资讯服务', 'about' => '', 'avatar' => 'img/mobile/article_app_icon.jpg', 'callback' => '');
     return $apps;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:8,代码来源:MobileSchoolUtil.php

示例11: convert

 public function convert($id)
 {
     $post = ServiceKernel::instance()->createService('Course.ThreadService')->getPost(1, $id);
     if (empty($post)) {
         throw new \Exception('course-thread-post not found');
     }
     return $post;
 }
开发者ID:mm999,项目名称:EduSoho,代码行数:8,代码来源:CourseThreadPostConvert.php

示例12: convert

 public function convert($id)
 {
     $announcement = ServiceKernel::instance()->createService('Announcement.AnnouncementService')->getAnnouncement($id);
     if (empty($announcement)) {
         throw new \Exception('announcement not found');
     }
     return $announcement;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:8,代码来源:AnnouncementConvert.php

示例13: convert

 public function convert($id)
 {
     $sundry = ServiceKernel::instance()->createService('sundry.sundryService')->getSundry($id);
     if (empty($sundry)) {
         throw new \Exception('user not found');
     }
     return $sundry;
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:8,代码来源:SundryConvert.php

示例14: convert

 public function convert($id)
 {
     $homework = ServiceKernel::instance()->createService('Homework:Homework.HomeworkService')->gethomework($id);
     if (empty($homework)) {
         throw new \Exception('user not found');
     }
     return $homework;
 }
开发者ID:latticet,项目名称:EduSoho_jb51,代码行数:8,代码来源:HomeworkConvert.php

示例15: convert

 public function convert($id)
 {
     $exercise = ServiceKernel::instance()->createService('Homework:Homework.ExerciseService')->getExercise($id);
     if (empty($exercise)) {
         throw new \Exception('exercise not found');
     }
     return $exercise;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:8,代码来源:ExerciseConvert.php


注:本文中的Topxia\Service\Common\ServiceKernel::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。