當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。