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


PHP Http\Request类代码示例

本文整理汇总了PHP中Slim\Http\Request的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test

 public function test(Request $request, Response $response, array $args)
 {
     $uid = $args['uid'];
     $myaccount = R::load('accounts', $uid);
     $accountId = $myaccount->accountid;
     $account = R::findOne('accounts', ' accountid = ?', [$accountId]);
     if (!empty($account)) {
         $apiKey = $account['apikey'];
         $type = $account['servertype'];
         $oandaInfo = new Broker_Oanda($type, $apiKey, $accountId);
     } else {
         $this->flash->addMessage('flash', "Oanda AccountId not found");
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('homepage'));
     }
     $side = 'buy';
     $pair = 'EUR_USD';
     $price = '1.1400';
     $expiry = time() + 60;
     $stopLoss = '1.1300';
     $takeProfit = NULL;
     $risk = 1;
     //        $side='buy';
     //        $pair='GBP_CHF';
     //        $price='2.1443';
     //        $expiry = $oandaInfo->getExpiry(time()+60);
     //        $stopLoss='2.1452';
     //        $takeProfit=NULL;
     //        $risk=1;
     //$oandaInfo->placeLimitOrder($side,$pair,$price,$expiry,$stopLoss,$takeProfit,$risk);
     $oandaInfo->processTransactions();
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:31,代码来源:TestAction.php

示例2: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $teacherId = $req->getParam('teacher_id');
     $teacher = $this->staffService->getTeacherById($teacherId);
     if ($teacher['school_id'] !== $school->id) {
         return $res->withStatus(403, 'No school');
     }
     if ($req->isPost()) {
         $inputFilter = $this->inputFilter;
         $result = $inputFilter($req->getParams());
         if (!$result['is_valid']) {
             $res = $res->withStatus(422);
             $res = $res->withJson($result);
             return $res;
         }
         $this->service->saveAnswers($teacherId, $result['values']);
     }
     $data = $this->service->getAnswers($teacherId);
     $res = $res->withJson($data);
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:25,代码来源:SurveyForm.php

示例3: __invoke

 public function __invoke(Request $request, Response $response, callable $next)
 {
     $request->registerMediaTypeParser('application/json', function ($input) {
         return json_decode($input);
     });
     return $next($request, $response);
 }
开发者ID:Gerschtli,项目名称:time-manager,代码行数:7,代码来源:JsonConverter.php

示例4: login

 public function login(Request $request, Response $response, array $args)
 {
     $this->logger->info("Login page action dispatched");
     $username = null;
     $error = null;
     $urlRedirect = $this->router->pathFor('homepage');
     //        if ($request->getAttribute('r') && $request->getAttribute('r') != '/logout' && $request->getAttribute('r') != '/login') {
     //            $_SESSION['urlRedirect'] = $request->getAttribute('r');
     //        }
     if (isset($_SESSION['urlRedirect'])) {
         $urlRedirect = $_SESSION['urlRedirect'];
         unset($_SESSION['urlRedirect']);
     }
     if ($request->isPost()) {
         $username = $request->getParam('username');
         $password = $request->getParam('password');
         $result = $this->authenticator->authenticate($username, $password);
         if ($result->isValid()) {
             //$error = $this->authenticator->getIdentity();
             return $response->withRedirect($urlRedirect);
         } else {
             $messages = $result->getMessages();
             $error = (string) $messages[0];
             //$this->flash->addMessage('flash', $error);
         }
     }
     $this->view->render($response, 'login.twig', ['username' => $username, 'error' => $error]);
     return $response;
 }
开发者ID:aodkrisda,项目名称:oncallslim,代码行数:29,代码来源:LoginAction.php

示例5: edit

 public function edit(Request $request, Response $response, array $args)
 {
     $input = $request->getParsedBody();
     /** @var MemberPortfolios $portfolio */
     $portfolio = $this->data(MemberPortfolios::class);
     $validator = $this->validator->rule('required', ['company_name', 'industry_id', 'start_date_y', 'work_status', 'job_title', 'job_desc']);
     if ($input['work_status'] == 'R') {
         $validator->rule('required', 'end_date_y');
     }
     if ($validator->validate()) {
         if ($input['work_status'] == 'A') {
             unset($input['end_date_y'], $input['end_date_m'], $input['end_date_d']);
         }
         try {
             $update = $portfolio->update($input, (int) $args['id']);
             $message = 'Item portfolio berhasil diperbaharui. Selamat!';
         } catch (\PDOException $e) {
             $update = false;
             $message = 'System error!<br>' . $e->getMessage();
         }
         $this->addFormAlert($update !== false ? 'success' : 'error', $message);
     } else {
         $this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors());
         return $response->withRedirect($this->router->pathFor('membership-portfolios-edit', $args));
     }
     return $response->withRedirect($this->router->pathFor('membership-account'));
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:27,代码来源:PortfoliosController.php

示例6: __invoke

 public function __invoke(Request $req, Response $res, array $args = [])
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $params = $req->getParams();
     $id = $params['id'];
     $params['school_id'] = $school->id;
     if (isset($params['lessons']) && !is_array($params['lessons'])) {
         $params['lessons'] = explode(',', $params['lessons']);
     }
     unset($params['id']);
     try {
         if ($id) {
             $lab = $this->labservice->updateLab($params, $id);
             $res = $res->withStatus(200);
         } else {
             $lab = $this->labservice->createLab($params);
             $res = $res->withStatus(201);
         }
         $res = $res->withJson($lab);
     } catch (Exception $ex) {
         $res = $res->withStatus(500, $ex->getMessage());
     }
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:27,代码来源:PersistLab.php

示例7: listMedia

 public function listMedia(Request $request, Response $response, $arguments)
 {
     $media = $this->container->MediaService->getAllMedia();
     $media = collect($media)->values();
     $baseUrl = $request->getUri()->getBaseUrl();
     $media = $media->map(function ($item) use($baseUrl) {
         $item['is_image'] = false;
         if ($this->isImage($item)) {
             $imagick = $this->manager->make($item['full_name_with_path']);
             $item['height'] = $imagick->height();
             $item['width'] = $imagick->width();
             $item['is_image'] = true;
         }
         $item['url'] = $baseUrl . '/uploads/' . $item['full_name'];
         if ($this->isPdf($item)) {
             $item['thumbnail'] = $baseUrl . '/api/media/thumbnail/' . $item['full_name'];
         } elseif ($this->isImage($item)) {
             $item['thumbnail'] = $item['url'];
         } else {
             $item['thumbnail'] = null;
         }
         $item['downloadUrl'] = $baseUrl . '/api/media/download/' . $item['full_name'];
         return $item;
     });
     return $response->withJson($media);
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:26,代码来源:MediaController.php

示例8: rememberme

 public function rememberme(Request $request)
 {
     if (false === SecurityController::AppAuthorization()) {
         $tockenAccess = false;
         $cookies = $request->getCookieParams();
         foreach ($cookies as $cookie => $value) {
             if ('Rememberme' === $cookie) {
                 $tockenAccess = $value;
                 break;
             }
         }
         /*
         $cookies = explode(';', $request->getHeaders()['HTTP_COOKIE'][0]);
         foreach($cookies As $cookie)
         {
             if(trim(stristr($cookie, '=', true)) === 'Rememberme') {
                 $tockenAccess = trim(substr(stristr($cookie, '=', false), 1));
                 break;
             }
         }
         */
         if (false !== $tockenAccess) {
             $security = new SecurityController();
             return $security->tockenAuthenticate($tockenAccess);
         }
     }
     return false;
 }
开发者ID:inkstudiocompany,项目名称:mastertk,代码行数:28,代码来源:SecurityMiddleware.php

示例9: learningcenterRemove

 public function learningcenterRemove(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $db->delete("learningcenter", ["id" => $attr["id"]]);
     return $res->withHeader("Location", $req->getUri()->getBasePath() . "/learningcenter");
 }
开发者ID:nuiz,项目名称:gis,代码行数:7,代码来源:LearningCenterController.php

示例10: login

 /**
  * Intermediario entre el Front-End y el servicio.
  *
  * @param Request $request
  *
  * @return []
  */
 public function login($request)
 {
     $result = [];
     $formData = $request->getParsedBody();
     $email = null;
     $password = null;
     // Verificamos que efectivamente exista una entrada de email
     if (array_key_exists("email", $formData)) {
         $email = $formData["email"];
     }
     // Verificamos que efectivamente exista una entrada de password
     if (array_key_exists("password", $formData)) {
         $password = $formData["password"];
     }
     if (isset($email, $password)) {
         $loginResult = $this->userService->login($email, $password);
         if (array_key_exists("error", $loginResult)) {
             $result["error"] = true;
         } else {
             setcookie($this->nombreCookie, true, time() + 3600);
         }
         $result["message"] = $loginResult["message"];
     } else {
         $result["error"] = true;
         $result["message"] = "Email and password can not be empty.";
     }
     return $result;
 }
开发者ID:meluk,项目名称:UProyecto1,代码行数:35,代码来源:UserController.php

示例11: productRemove

 public function productRemove(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $db->delete("product", ["id" => $attr["id"]]);
     $db->delete("person_cripple", ["cripple_id" => $attr["id"]]);
     return $res->withHeader("Location", $req->getUri()->getBasePath() . "/product");
 }
开发者ID:icezlizz1991,项目名称:tufftexgroup,代码行数:8,代码来源:ProductController.php

示例12: getMunicipioDepartamento

 function getMunicipioDepartamento(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $id = $request->getAttribute("id");
     $data = Municipio::select("municipio.*", "departamento.nombre as departamento")->join('departamento', 'departamento.id', '=', 'municipio.idDepartamento')->where("municipio.id", "=", $id)->first();
     $response->getBody()->write($data);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:8,代码来源:MunicipioControl.php

示例13: disavantaged_typeRemove

 public function disavantaged_typeRemove(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $db->delete("disavantaged_type", ["id" => $attr["id"]]);
     $db->delete("person_disavantaged", ["disavantaged_id" => $attr["id"]]);
     return $res->withHeader("Location", $req->getUri()->getBasePath() . "/disavantaged_type");
 }
开发者ID:nuiz,项目名称:gis,代码行数:8,代码来源:DisavantagedTypeController.php

示例14: promedio

 public function promedio(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $idCliente = $request->getAttribute("idCliente");
     $query = "SELECT COALESCE(AVG(calificacion),0) as promedio FROM calificacioncliente WHERE idCliente = " . $idCliente;
     $data = DB::select(DB::raw($query));
     $response->getBody()->write(json_encode($data));
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:CalificacionClienteControl.php

示例15: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $this->service->setTotalTeachers($school->id, (int) $req->getParam('total_teachers', 0));
     return $res->withStatus(204);
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:9,代码来源:SubmitTeachersCount.php


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