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


PHP Request::getUri方法代码示例

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


在下文中一共展示了Request::getUri方法的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: product_mediaRemove

 public function product_mediaRemove(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $media = $db->get("product_media", "*", ["id" => $attr["id"]]);
     if (!$media) {
         return $res->withHeader("Location", $req->getUri()->getBasePath() . "/product/" . $attr["product_id"] . "/media");
     }
     if ($media["type"] == "image") {
         @unlink("../product_media/" . $media["image_path"]);
     }
     $db->delete("product_media", ["id" => $attr["id"]]);
     return $res->withHeader("Location", $req->getUri()->getBasePath() . "/product/" . $attr["product_id"] . "/media");
 }
开发者ID:icezlizz1991,项目名称:tufftexgroup,代码行数:14,代码来源:ProductMediaController.php

示例3: __invoke

 public function __invoke(Request $req, Response $res, callable $next)
 {
     $path = $req->getUri()->getPath();
     $path = "/" . trim($path, "/");
     $allowNotAuth = ["/", "/login"];
     if (!in_array($path, $allowNotAuth)) {
         /** @var Aura\Session\Session */
         $session = $this->container["session"];
         $loginSegment = $session->getSegment("login");
         if (empty($loginSegment->get("user"))) {
             return $res->withHeader("Location", $req->getUri()->getBasePath() . "/login");
         }
     }
     return $next($req, $res);
 }
开发者ID:icezlizz1991,项目名称:tufftexgroup,代码行数:15,代码来源:AuthMiddleware.php

示例4: edit

 public function edit(Request $request, Response $response, array $args)
 {
     $uid = $args['uid'];
     if (empty($uid)) {
         $this->flash->addMessage('flash', 'No record specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
     }
     $id = $this->authenticator->getIdentity();
     $user = R::load('users', $id['id']);
     if ($uid != 'new') {
         $account = R::load('accounts', $uid);
         if ($account->id == 0) {
             $this->flash->addMessage('flash', 'No record found');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
         }
         // restrict access to own profile or Admin role
         if ($account->users->id != $id['id']) {
             if (strtolower($id['role']) != 'admin') {
                 $this->flash->addMessage('flash', 'Access Denied');
                 return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
             }
         }
     } else {
         $account = R::dispense('accounts');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         $account->import($data, 'apikey,accountid,servertype');
         $account->users = $user;
         $account->lasttid = 0;
         $oandaInfo = FALSE;
         // verify and get account balance
         try {
             $oandaInfo = new Broker_Oanda($account['servertype'], $account['apikey'], $account['accountid'], 0);
         } catch (\Exception $e) {
             $viewData['flash'] = 'Account Details Invalid';
         }
         if ($oandaInfo != FALSE) {
             $aid = R::store($account);
             $oandaInfo->updateAccount();
             $this->flash->addMessage('flash', "account updated");
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('editaccount', ['uid' => $aid]));
         }
     }
     $viewData['account'] = $account;
     $this->view->render($response, 'account.twig', $viewData);
     return $response;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:48,代码来源:AccountAction.php

示例5: 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

示例6: __invoke

 /**
  * Execute the middleware.
  *
  * @param  \Slim\Http\Request  $req
  * @param  \Slim\Http\Response $res
  * @param  callable            $next
  * @return \Slim\Http\Response
  */
 public function __invoke(Request $req, Response $res, callable $next)
 {
     $uri = $req->getUri();
     $path = $this->filterTrailingSlash($uri);
     if ($uri->getPath() !== $path) {
         return $res->withStatus(301)->withHeader('Location', $path)->withBody($req->getBody());
     }
     //        if ($this->filterBaseurl($uri)) {
     //            return $res->withStatus(301)
     //                ->withHeader('Location', (string) $uri)
     //                ->withBody($req->getBody());
     //        }
     $server = $req->getServerParams();
     if (!isset($server['REQUEST_TIME_FLOAT'])) {
         $server['REQUEST_TIME_FLOAT'] = microtime(true);
     }
     $uri = $uri->withPath($path);
     $req = $this->filterRequestMethod($req->withUri($uri));
     $res = $next($req, $res);
     $res = $this->filterPrivateRoutes($uri, $res);
     // Only provide response calculation time in non-production env, tho.
     if ($this->settings['mode'] !== 'production') {
         $time = (microtime(true) - $server['REQUEST_TIME_FLOAT']) * 1000;
         $res = $res->withHeader('X-Response-Time', sprintf('%2.3fms', $time));
     }
     return $res;
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:35,代码来源:CommonMiddleware.php

示例7: 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

示例8: deleteUser

 public function deleteUser(Request $request, Response $response, array $args)
 {
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users'));
     }
     $user = R::findOne('users', ' email = ? ', [$name]);
     if (!empty($user)) {
         R::trash($user);
         $this->flash->addMessage('flash', "{$name} deleted");
     } else {
         $this->flash->addMessage('flash', "{$name} User not found");
     }
     return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users'));
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:16,代码来源:UserAction.php

示例9: 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

示例10: 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

示例11: dispatch

 public function dispatch(Request $request, Response $response, array $args)
 {
     $this->logger->info("Oncall page action dispatched");
     $rota = strtolower($args['rota']);
     $display = isset($args['display']) ? $args['display'] : 6;
     $prev = $request->getParam('prev', 0);
     $dis = 5;
     $loggedIn = $this->authenticator->hasIdentity();
     $comments = "";
     $rotaBean = R::findOne('rotas', ' name = :name ', [':name' => $rota]);
     if (empty($rotaBean)) {
         $this->flash->addMessage('flash', "sorry {$rota} not found");
         return $response->withRedirect($this->router->pathFor('homepage'));
     }
     $title = $rotaBean->title;
     $users = $rotaBean->sharedUsersList;
     $months = [];
     $colour = [];
     $data = [];
     if (!empty($prev)) {
         $thisMonth = date("n") - 2;
     } else {
         $thisMonth = date("n") - 1;
     }
     $thisYear = date("Y");
     if ($thisMonth < 1) {
         $thisMonth = $thisMonth + 12;
         $thisYear = $thisYear - 1;
     }
     for ($i = 1; $i < $display + 1; $i++) {
         $thisMonth++;
         if ($thisMonth == 13) {
             $thisMonth = 1;
             $thisYear++;
         }
         $months[$i] = $thisYear . "-" . $thisMonth . "-1";
         if ($loggedIn) {
             foreach (range(1, 31) as $dayCount) {
                 $data[$i][$dayCount] = "<a href=\"" . $request->getUri()->getBaseUrl() . "/change/{$rota}?day={$dayCount}&month={$thisMonth}&year={$thisYear}&prev={$prev}\">{$dayCount}</a>";
             }
         } else {
             $data[$i] = range(0, 31);
         }
         foreach (range(1, 31) as $dayCount) {
             $rotaDay = R::findOne($rota, ' month = :month AND year = :year AND day = :day ', [':day' => $dayCount, ':month' => $thisMonth, ':year' => $thisYear]);
             if (!empty($rotaDay)) {
                 $onCallUser = $rotaDay->fetchAs('users')->name;
                 $colour[$i][$dayCount] = $onCallUser->colour;
                 //"#6622" . ($dayCount + 10);
             } else {
                 $colour[$i][$dayCount] = "#fefefe";
             }
         }
     }
     $onCallNow = $this->getOnCallNow($rota);
     $this->view->render($response, 'oncall.twig', ['rota' => $rota, 'title' => $title, 'comments' => $comments, 'months' => $months, 'data' => $data, 'colour' => $colour, 'users' => $users, 'formatDate' => date("l jS F Y,  g:ia"), 'onCallNow' => $onCallNow]);
     return $response;
 }
开发者ID:aodkrisda,项目名称:oncallslim,代码行数:58,代码来源:OncallAction.php

示例12: anyLogout

 public function anyLogout(Request $req, Response $res)
 {
     $container = $this->slim->getContainer();
     /** @var Aura\Session\Session */
     $session = $container->session;
     $loginSegment = $session->getSegment("login");
     $loginSegment->clear();
     $session->commit();
     return $res->withHeader("Location", $req->getUri()->getBasePath() . "/login");
 }
开发者ID:nuiz,项目名称:gis,代码行数:10,代码来源:IndexController.php

示例13: auth

 public function auth(Request $request, Response $response, callable $next)
 {
     $auth = $this->authenticator;
     $role = $this->getRole($auth->getIdentity());
     $hasIdentity = $auth->hasIdentity();
     $identity = $auth->getIdentity();
     //        $data = array(
     //            'hasIdentity' => $hasIdentity,
     //            'role' => $role,
     //            'identity' => $identity
     //        );
     if (!$hasIdentity) {
         //throw new HttpUnauthorizedException();
         $_SESSION['urlRedirect'] = (string) $request->getUri();
         //$app->flash('error', 'Login required');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('login'));
     }
     /* Everything ok, call next middleware. */
     $response = $next($request, $response);
     return $response;
 }
开发者ID:neilmillard,项目名称:authenticator,代码行数:21,代码来源:Middleware.php

示例14: __invoke

 /**
  * Execute the middleware.
  *
  * @param Request  $request
  * @param Response $response
  * @param callable $next
  *
  * @return Response
  */
 public function __invoke(Request $request, Response $response, callable $next)
 {
     // Overwrite request with new uri path
     $uri = $request->getUri();
     $request = $request->withUri($uri->withPath($this->path));
     // Overwrite params (if provided)
     if (!empty($this->params)) {
         $request = $request->withQueryParams($this->params);
     }
     // Call next middleware
     return $next($request, $response);
 }
开发者ID:ansas,项目名称:php-component,代码行数:21,代码来源:ForceRoute.php

示例15: editUser

 public function editUser(Request $request, Response $response, array $args)
 {
     $username = $args['username'];
     if (empty($username)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
     }
     $username = base64_decode($username);
     $id = $this->authenticator->getIdentity();
     // restrict access to own profile or Admin role
     if ($username != strtolower($id['email'])) {
         if (strtolower($id['role']) != 'admin') {
             $this->flash->addMessage('flash', 'Access Denied');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
         }
     }
     $user = R::findOne('users', ' email = ? ', [$username]);
     if ($user == NULL) {
         $user = R::dispense('users');
     }
     if ($request->isPost()) {
         $user->fullname = $request->getParam('userfullname');
         $user->email = $request->getParam('username');
         $password = $request->getParam('userpassword');
         if (!empty($password)) {
             $pass = password_hash($password, PASSWORD_DEFAULT);
             $user->hash = $pass;
         }
         $id = R::store($user);
         $this->flash->addMessage('flash', "{$user->name} updated");
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('edituser', ['username' => base64_encode($username)]));
     }
     $expUser['user'] = $user->export();
     $expUser['user']['hashemail'] = base64_encode($user['email']);
     $this->view->render($response, 'user.twig', $expUser);
     return $response;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:37,代码来源:ProfileAction.php


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