本文整理匯總了PHP中Magento\Framework\App\RequestInterface::getScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestInterface::getScheme方法的具體用法?PHP RequestInterface::getScheme怎麽用?PHP RequestInterface::getScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getScheme方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCurrentUrl
/**
* Retrieve current url
*
* @return string
*/
public function getCurrentUrl()
{
$port = $this->_request->getServer('SERVER_PORT');
if ($port) {
$defaultPorts = [\Magento\Framework\App\Request\Http::DEFAULT_HTTP_PORT, \Magento\Framework\App\Request\Http::DEFAULT_HTTPS_PORT];
$port = in_array($port, $defaultPorts) ? '' : ':' . $port;
}
$requestUri = $this->_request->getServer('REQUEST_URI');
$url = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $port . $requestUri;
return $url;
}
示例2: getCurrentUrl
/**
* Retrieve current url
*
* @return string
*/
public function getCurrentUrl()
{
$httpHostWithPort = $this->_request->getHttpHost(false);
$httpHostWithPort = explode(':', $httpHostWithPort);
$httpHost = isset($httpHostWithPort[0]) ? $httpHostWithPort[0] : '';
$port = '';
if (isset($httpHostWithPort[1])) {
$defaultPorts = [\Magento\Framework\App\Request\Http::DEFAULT_HTTP_PORT, \Magento\Framework\App\Request\Http::DEFAULT_HTTPS_PORT];
if (!in_array($httpHostWithPort[1], $defaultPorts)) {
/** Custom port */
$port = ':' . $httpHostWithPort[1];
}
}
return $this->_request->getScheme() . '://' . $httpHost . $port . $this->_request->getRequestUri();
}
示例3: getRequestUrl
/**
* Compute the request Url from the Http request
*
* @param RequestInterface $httpRequest
* @return string
*/
public function getRequestUrl($httpRequest)
{
return $httpRequest->getScheme() . '://' . $httpRequest->getHttpHost(false) . $httpRequest->getRequestUri();
}