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


PHP RequestInterface::getServer方法代码示例

本文整理汇总了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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Header.php

示例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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:RemoteAddress.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:Redirect.php

示例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;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:Url.php

示例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;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:19,代码来源:Url.php

示例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');
 }
开发者ID:kid17,项目名称:magento2,代码行数:20,代码来源:Url.php

示例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;
 }
开发者ID:mrbadao,项目名称:magento-ce,代码行数:21,代码来源:Store.php

示例8: _getDocumentRoot

 /**
  * Get Document root of Magento instance
  *
  * @return string
  */
 protected function _getDocumentRoot()
 {
     return $this->_request->getServer('DOCUMENT_ROOT');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:9,代码来源:Sitemap.php

示例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');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:DocRootLocator.php


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