本文整理汇总了PHP中Illuminate\Http\Request::getScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getScheme方法的具体用法?PHP Request::getScheme怎么用?PHP Request::getScheme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::getScheme方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getScheme
/**
* Get the scheme for a raw URL.
*
* @param bool|null $secure
* @return string
*/
protected function getScheme($secure)
{
if (is_null($secure)) {
return $this->forceSchema ?: $this->request->getScheme() . '://';
}
return $secure ? 'https://' : 'http://';
}
示例2: handle
/**
* Handle an incoming request, check to see if we have a redirect in place for the requested URL
* and then redirect if we do have a match
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Get the full URL that has been requested, minus the protocol
$full_url = str_replace($request->getScheme() . "://", "", $request->url());
// Check for any results matching the full domain request
$results = Redirect::where("type", "domain")->where("from", $full_url)->where("status", "active");
if ($results->exists()) {
// Get the first result back
$redirect = $results->first();
// Grab the URL before we increment
$url = $redirect->to;
// Increment the hit count
$redirect->increment('hits');
// Redirect off to where we're going
return RedirectFacade::to($url);
}
// Check for any results matching the path only
$results = Redirect::where("type", "path")->where("from", "/" . $request->path())->where("status", "active");
// If a redirect exists for this, process it and redirect
if ($results->exists()) {
// Get the first result back
$redirect = $results->first();
// Grab the URL before we increment
$url = $redirect->to;
// Increment the hit count
$redirect->increment('hits');
// Redirect off to where we're going
return RedirectFacade::to($url, 301);
}
// By default, continue afterwards and bail out
return $next($request);
}
示例3: localizedURL
/**
* Returns an URL adapted to locale
*
* @param string $locale
* @return string
*/
private function localizedURL($locale)
{
// Default language doesn't get a special subdomain
$locale = $locale !== $this->defaultLocale ? strtolower($locale) . '.' : '';
// URL elements
$uri = $this->request->getRequestUri();
$scheme = $this->request->getScheme();
// Get host
$array = explode('.', $this->request->getHttpHost());
$host = (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1];
// Create URL from template
$url = str_replace(['[scheme]', '[locale]', '[host]', '[uri]'], [$scheme, $locale, $host, $uri], $this->config['locale_url']);
return url($url);
}
示例4: getLocalizedURL
/**
* Returns an URL adapted to $locale
*
* @throws SupportedLocalesNotDefined
* @throws UnsupportedLocaleException
*
* @param string|boolean $locale Locale to adapt, false to remove locale
* @param string|false $url URL to adapt in the current language. If not passed, the current url would be
* taken.
* @param array $attributes Attributes to add to the route, if empty, the system would try to extract
* them from the url.
*
*
* @return string|false URL translated, False if url does not exist
*/
public function getLocalizedURL($locale = null, $url = null, $attributes = [])
{
// Use default if not set
if ($locale === null) {
$locale = $this->getCurrentLocale();
}
// Get request Uri
if (empty($url)) {
$url = $this->request->getRequestUri();
} else {
$parts = parse_url($url);
$url = $parts['path'] . (isset($parts['query']) ? '?' . $parts['query'] : '');
}
$scheme = $this->request->getScheme();
$locale = $locale && $locale !== $this->getDefaultLocale() ? "{$locale}." : '';
// Get host
$array = explode('.', $this->request->getHttpHost());
$host = (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1];
return app('url')->to("{$scheme}://{$locale}{$host}{$url}", $attributes);
}
示例5: getScheme
/**
* Gets the request's scheme.
*
* @return string
* @static
*/
public static function getScheme()
{
//Method inherited from \Symfony\Component\HttpFoundation\Request
return \Illuminate\Http\Request::getScheme();
}
示例6: setRequestData
/**
* @param $data
* @return array
*/
protected function setRequestData(array $data)
{
$data['original_headers'] = $this->httpRequest->headers->all();
$data['request'] = ['host' => $this->httpRequest->getHost(), 'method' => $this->httpRequest->method(), 'scheme' => $this->httpRequest->getScheme()];
return $data;
}
示例7: getRequestContext
/**
* @param \Illuminate\Http\Request $request
* @return string
*/
public function getRequestContext(Request $request)
{
return implode('.', [$request->getScheme(), strtolower($request->getMethod()), $this->guessRequestType($request), '_' . $this->quotePath($request->getPathInfo())]);
}