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


PHP Request::getSchemeAndHttpHost方法代码示例

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


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

示例1: getSchemeAndHttpHost

 /**
  * Gets the scheme and HTTP host.
  *
  * If the URL was called with basic authentication, the user
  * and the password are not added to the generated string.
  *
  * @return string The scheme and HTTP host
  */
 public function getSchemeAndHttpHost()
 {
     return parent::getSchemeAndHttpHost();
 }
开发者ID:andrims21,项目名称:eBri,代码行数:12,代码来源:Request.php

示例2: login

 /**
  * Handle logging in / logging out a user.
  *
  * @return Response
  */
 public function login()
 {
     $status = 401;
     try {
         // Set login credentials
         $credentials = array('email' => Request::getUser(), 'password' => Request::getPassword());
         // Try to authenticate the user
         $response = Sentry::authenticate($credentials, false);
         $status = 200;
     } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $response = array('message' => 'Provided information is not valid.', 'errors' => array(array('field' => 'email', 'message' => 'Login field is required.')));
     } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $response = array('message' => 'Provided information is not valid.', 'errors' => array(array('field' => 'password', 'message' => 'Password field is required.')));
     } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) {
         $response = array('message' => 'Provided information is not valid.', 'errors' => array(array('field' => 'password', 'message' => 'Wrong password, try again.')));
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $response = array('message' => 'User was not found.');
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $response = array('message' => 'Your account is not yet activated.');
     } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $response = array('message' => 'Your account is suspended.');
     } catch (\Cartalyst\Sentry\Throttling\UserBannedException $e) {
         $response = array('message' => 'Your account is banned.');
     }
     // Get current client
     $client = API::getClient();
     // Logging in user
     if ($status == 200) {
         $clientEndpoint = $client->endpoint;
         $clientScopeIds = API::getResource()->getScopeIds();
         $clientScopes = API::getResource()->getScopes();
         $scopes = array();
         if (!empty($clientScopeIds)) {
             foreach ($clientScopeIds as $id) {
                 $scopes[] = array('id' => $id);
             }
         }
         unset($clientScopeIds);
         if (!is_array($clientScopes)) {
             $clientScopes = array();
         }
         // Create a new client endpoint if not exist
         if (!is_object($clientEndpoint)) {
             $redirectUri = Request::getSchemeAndHttpHost();
             $clientEndpoint = OauthClientEndpoint::create(array('client_id' => $client->id, 'redirect_uri' => $redirectUri));
         } else {
             $redirectUri = $clientEndpoint->redirect_uri;
         }
         // Create a new authorization code
         $authCode = API::newAuthorizeRequest('user', $response->id, array('client_id' => $client->id, 'redirect_uri' => $redirectUri, 'scopes' => $scopes));
         // Authorize the client to a user
         if (!empty($authCode)) {
             $params = array('grant_type' => 'authorization_code', 'client_id' => $client->id, 'client_secret' => $client->secret, 'redirect_uri' => $redirectUri, 'code' => $authCode, 'scope' => implode(',', $clientScopes), 'state' => time());
             $authorizationResponse = API::performAccessTokenFlow(false, $params);
             if (array_key_exists('status', $authorizationResponse)) {
                 $status = $authorizationResponse['status'];
                 $headers = $authorizationResponse['headers'];
                 unset($authorizationResponse['status']);
                 unset($authorizationResponse['headers']);
                 return API::resourceJson($authorizationResponse, $status, $headers);
             }
             // Merge user data with the new authorization data
             $authorizationResponse['user'] = new UserTemplate($response);
             $response = $authorizationResponse;
             unset($authorizationResponse);
         } else {
             $response = array('message' => 'There was a problem while logging you in, please try again or contact customer support.');
             $status = 500;
         }
         unset($scopes);
         unset($clientScopes);
         // Logout user
     } else {
         $user = null;
         try {
             $user = Sentry::getUser();
         } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         }
         if (!is_null($user) and !is_null($client)) {
             // Cleanup OAuth session
             $session = new FluentSession();
             $session->deleteSession($client->id, 'user', $user->getId());
             unset($session);
             // Logout user via sentry
             Sentry::logout();
         }
         unset($user);
     }
     return API::resourceJson($response, $status);
 }
开发者ID:WillymarJ,项目名称:Your-Laravel-Api,代码行数:95,代码来源:Auth.php

示例3: buildPagination

 /**
  * Build pagination link.
  *
  * @param  integer $total
  * @param  integer $offset
  * @param  integer $limit
  * @return string
  */
 private function buildPagination($total = 0, $offset = 0, $limit = 0)
 {
     $links = array();
     if ($total > 0) {
         $baseUrl = Request::getSchemeAndHttpHost() . Request::getPathInfo();
         // Create the first page link
         if ($offset > 0) {
             $param = array();
             $param['offset'] = 0;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="first"';
         }
         // Create the previous page link
         $prevOffset = $offset - $limit;
         if ($prevOffset > 0) {
             $param = array();
             $param['offset'] = $prevOffset;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="previous"';
         }
         // Create the next page link
         $nextOffset = $offset + $limit;
         if ($nextOffset < $total - $limit) {
             $param = array();
             $param['offset'] = $nextOffset;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="next"';
         }
         // Create the last page link
         if ($offset < $total - $limit) {
             $param = array();
             $param['offset'] = $total - $limit;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="last"';
         }
     }
     return implode(',', $links);
 }
开发者ID:WillymarJ,项目名称:Your-Laravel-Api,代码行数:54,代码来源:User.php


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