本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getServer方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getServer方法的具体用法?PHP RequestInterface::getServer怎么用?PHP RequestInterface::getServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getServer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getHttpCleanValue
/**
* Retrieve HTTP "clean" value
*
* @param string $var
* @param boolean $clean clean non UTF-8 characters
* @return string
*/
protected function _getHttpCleanValue($var, $clean = true)
{
$value = $this->_request->getServer($var, '');
if ($clean) {
$value = $this->_converter->cleanString($value);
}
return $value;
}
示例2: getRemoteAddress
/**
* Retrieve Client Remote Address
*
* @param bool $ipToLong converting IP to long format
* @return string IPv4|long
*/
public function getRemoteAddress($ipToLong = false)
{
if ($this->remoteAddress === null) {
foreach ($this->alternativeHeaders as $var) {
if ($this->request->getServer($var, false)) {
$this->remoteAddress = $this->request->getServer($var);
break;
}
}
if (!$this->remoteAddress) {
$this->remoteAddress = $this->request->getServer('REMOTE_ADDR');
}
}
if (!$this->remoteAddress) {
return false;
}
return $ipToLong ? ip2long($this->remoteAddress) : $this->remoteAddress;
}
示例3: _getUrl
/**
* @return string
*/
protected function _getUrl()
{
$refererUrl = $this->_request->getServer('HTTP_REFERER');
$url = (string) $this->_request->getParam(self::PARAM_NAME_REFERER_URL);
if ($url) {
$refererUrl = $url;
}
$url = $this->_request->getParam(\Magento\Framework\App\Action\Action::PARAM_NAME_BASE64_URL);
if ($url) {
$refererUrl = $this->_urlCoder->decode($url);
}
$url = $this->_request->getParam(\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED);
if ($url) {
$refererUrl = $this->_urlCoder->decode($url);
}
if (!$this->_isUrlInternal($refererUrl)) {
$refererUrl = $this->_storeManager->getStore()->getBaseUrl();
}
return $refererUrl;
}
示例4: 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;
}
示例5: isOwnOriginUrl
/**
* Check if users originated URL is one of the domain URLs assigned to scopes
*
* @return boolean
*/
public function isOwnOriginUrl()
{
$scopeDomains = [];
$referer = parse_url($this->_request->getServer('HTTP_REFERER'), PHP_URL_HOST);
foreach ($this->_scopeResolver->getScopes() as $scope) {
$scopeDomains[] = parse_url($scope->getBaseUrl(), PHP_URL_HOST);
$scopeDomains[] = parse_url($scope->getBaseUrl(UrlInterface::URL_TYPE_LINK, true), PHP_URL_HOST);
}
$scopeDomains = array_unique($scopeDomains);
if (empty($referer) || in_array($referer, $scopeDomains)) {
return true;
}
return false;
}
示例6: 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->getServer('REQUEST_URI');
}
示例7: isCurrentlySecure
/**
* Check if request was secure
*
* @return boolean
*/
public function isCurrentlySecure()
{
if ($this->_request->isSecure()) {
return true;
}
$secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
$secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE);
if (!$secureBaseUrl || !$secureFrontend) {
return false;
}
$uri = \Zend_Uri::factory($secureBaseUrl);
$port = $uri->getPort();
$serverPort = $this->_request->getServer('SERVER_PORT');
$isSecure = $uri->getScheme() == 'https' && isset($serverPort) && $port == $serverPort;
return $isSecure;
}
示例8: _getDocumentRoot
/**
* Get Document root of Magento instance
*
* @return string
*/
protected function _getDocumentRoot()
{
return $this->_request->getServer('DOCUMENT_ROOT');
}
示例9: isPub
/**
* Returns true if doc root is pub/ and not BP
*
* @return bool
*/
public function isPub()
{
$rootBasePath = $this->request->getServer('DOCUMENT_ROOT');
$readDirectory = $this->readFactory->create(DirectoryList::ROOT);
return substr($rootBasePath, -strlen('/pub')) === '/pub' && !$readDirectory->isExist($rootBasePath . 'setup');
}