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


PHP RequestInterface::getHttpHost方法代码示例

本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getHttpHost方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getHttpHost方法的具体用法?PHP RequestInterface::getHttpHost怎么用?PHP RequestInterface::getHttpHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getHttpHost方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUris

 /**
  * Get cache servers' Uris
  *
  * @return Uri[]
  */
 public function getUris()
 {
     $servers = [];
     $configuredHosts = $this->config->get(ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS);
     if (null == $configuredHosts) {
         $httpHost = $this->request->getHttpHost();
         $servers[] = $httpHost ? UriFactory::factory('')->setHost($httpHost)->setPort(self::DEFAULT_PORT)->setScheme('http') : UriFactory::factory($this->urlBuilder->getUrl('*', ['_nosid' => true]))->setScheme('http')->setPath(null)->setQuery(null);
     } else {
         foreach ($configuredHosts as $host) {
             $servers[] = UriFactory::factory('')->setHost($host['host'])->setPort(isset($host['port']) ? $host['port'] : self::DEFAULT_PORT)->setScheme('http');
         }
     }
     return $servers;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Server.php

示例2: __construct

 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\String $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param string $scopeType
  * @param string $saveMethod
  * @param null|string $savePath
  * @param null|string $cacheLimiter
  * @param string $lifetimePath
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, $savePath = null, $cacheLimiter = null, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     $this->_scopeConfig = $scopeConfig;
     $this->_stringHelper = $stringHelper;
     $this->_httpRequest = $request;
     $this->_appState = $appState;
     $this->_filesystem = $filesystem;
     $this->_scopeType = $scopeType;
     $this->setSaveHandler($saveMethod === 'db' ? 'user' : $saveMethod);
     if (!$this->_appState->isInstalled() || !$savePath) {
         $savePath = $this->_filesystem->getPath('session');
     }
     $this->setSavePath($savePath);
     if ($cacheLimiter) {
         $this->setOption('session.cache_limiter', $cacheLimiter);
     }
     $lifetime = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, $this->_scopeType);
     $lifetime = is_numeric($lifetime) ? $lifetime : self::COOKIE_LIFETIME_DEFAULT;
     $this->setCookieLifetime($lifetime);
     $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
     if (empty($path)) {
         $path = $this->_httpRequest->getBasePath();
     }
     $this->setCookiePath($path);
     $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType);
     $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain;
     $this->setCookieDomain((string) $domain);
     $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:41,代码来源:Config.php

示例3: __construct

 /**
  * @param \Magento\Framework\ValidatorFactory $validatorFactory
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\String $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param Filesystem $filesystem
  * @param DeploymentConfig $deploymentConfig
  * @param string $scopeType
  * @param string $lifetimePath
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(\Magento\Framework\ValidatorFactory $validatorFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, Filesystem $filesystem, DeploymentConfig $deploymentConfig, $scopeType, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     $this->_validatorFactory = $validatorFactory;
     $this->_scopeConfig = $scopeConfig;
     $this->_stringHelper = $stringHelper;
     $this->_httpRequest = $request;
     $this->_scopeType = $scopeType;
     $saveMethod = $deploymentConfig->get(self::PARAM_SESSION_SAVE_METHOD, \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER);
     $savePath = $deploymentConfig->get(self::PARAM_SESSION_SAVE_PATH);
     $cacheLimiter = $deploymentConfig->get(self::PARAM_SESSION_CACHE_LIMITER);
     $this->setSaveHandler($saveMethod === 'db' ? 'user' : $saveMethod);
     if (!$savePath && !ini_get('session.save_path')) {
         $sessionDir = $filesystem->getDirectoryWrite(DirectoryList::SESSION);
         $savePath = $sessionDir->getAbsolutePath();
         $sessionDir->create();
     }
     if ($savePath) {
         $this->setSavePath($savePath);
     }
     if ($cacheLimiter) {
         $this->setOption('session.cache_limiter', $cacheLimiter);
     }
     $lifetime = $this->_scopeConfig->getValue($lifetimePath, $this->_scopeType);
     $this->setCookieLifetime($lifetime, self::COOKIE_LIFETIME_DEFAULT);
     $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
     $path = empty($path) ? $this->_httpRequest->getBasePath() : $path;
     $this->setCookiePath($path, $this->_httpRequest->getBasePath());
     $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType);
     $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain;
     $this->setCookieDomain((string) $domain, $this->_httpRequest->getHttpHost());
     $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType));
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:43,代码来源:Config.php

示例4: fetch

 /**
  * Make a http request and return response body
  *
  * @param  string $url
  * @return string
  */
 protected function fetch($url)
 {
     $client = $this->httpClientFactory->create();
     $client->setUri($url);
     $client->setConfig(['maxredirects' => 5, 'timeout' => 30]);
     $client->setParameterGet('domain', $this->request->getHttpHost());
     return $client->request()->getBody();
 }
开发者ID:swissup,项目名称:core,代码行数:14,代码来源:Remote.php

示例5: 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

示例6: __construct

 /**
  * @param \Magento\Framework\ValidatorFactory $validatorFactory
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param Filesystem $filesystem
  * @param DeploymentConfig $deploymentConfig
  * @param string $scopeType
  * @param string $lifetimePath
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(\Magento\Framework\ValidatorFactory $validatorFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\StringUtils $stringHelper, \Magento\Framework\App\RequestInterface $request, Filesystem $filesystem, DeploymentConfig $deploymentConfig, $scopeType, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     $this->_validatorFactory = $validatorFactory;
     $this->_scopeConfig = $scopeConfig;
     $this->_stringHelper = $stringHelper;
     $this->_httpRequest = $request;
     $this->_scopeType = $scopeType;
     /**
      * Session handler
      *
      * Save handler may be set to custom value in deployment config, which will override everything else.
      * Otherwise, try to read PHP settings for session.save_handler value. Otherwise, use 'files' as default.
      */
     $defaultSaveHandler = $this->getStorageOption('session.save_handler') ?: SaveHandlerInterface::DEFAULT_HANDLER;
     $saveMethod = $deploymentConfig->get(self::PARAM_SESSION_SAVE_METHOD, $defaultSaveHandler);
     $saveMethod = $saveMethod === 'db' ? 'user' : $saveMethod;
     $this->setSaveHandler($saveMethod);
     /**
      * Session path
      */
     $savePath = $deploymentConfig->get(self::PARAM_SESSION_SAVE_PATH);
     if (!$savePath && !ini_get('session.save_path')) {
         $sessionDir = $filesystem->getDirectoryWrite(DirectoryList::SESSION);
         $savePath = $sessionDir->getAbsolutePath();
         $sessionDir->create();
     }
     if ($savePath) {
         $this->setSavePath($savePath);
     }
     /**
      * Session cache limiter
      */
     $cacheLimiter = $deploymentConfig->get(self::PARAM_SESSION_CACHE_LIMITER);
     if ($cacheLimiter) {
         $this->setOption('session.cache_limiter', $cacheLimiter);
     }
     /**
      * Cookie settings: lifetime, path, domain, httpOnly. These govern settings for the session cookie.
      */
     $lifetime = $this->_scopeConfig->getValue($lifetimePath, $this->_scopeType);
     $this->setCookieLifetime($lifetime, self::COOKIE_LIFETIME_DEFAULT);
     $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
     $path = empty($path) ? $this->_httpRequest->getBasePath() : $path;
     $this->setCookiePath($path, $this->_httpRequest->getBasePath());
     $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType);
     $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain;
     $this->setCookieDomain((string) $domain, $this->_httpRequest->getHttpHost());
     $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:60,代码来源:Config.php

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

示例8: __construct

 /**
  * @param \Magento\Framework\ValidatorFactory $validatorFactory
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param Filesystem $filesystem
  * @param DeploymentConfig $deploymentConfig
  * @param string $scopeType
  * @param string $lifetimePath
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(\Magento\Framework\ValidatorFactory $validatorFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\StringUtils $stringHelper, \Magento\Framework\App\RequestInterface $request, Filesystem $filesystem, DeploymentConfig $deploymentConfig, $scopeType, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     $this->_validatorFactory = $validatorFactory;
     $this->_scopeConfig = $scopeConfig;
     $this->_stringHelper = $stringHelper;
     $this->_httpRequest = $request;
     $this->_scopeType = $scopeType;
     $this->lifetimePath = $lifetimePath;
     /**
      * Session path
      */
     $savePath = $deploymentConfig->get(self::PARAM_SESSION_SAVE_PATH);
     if (!$savePath && !ini_get('session.save_path')) {
         $sessionDir = $filesystem->getDirectoryWrite(DirectoryList::SESSION);
         $savePath = $sessionDir->getAbsolutePath();
         $sessionDir->create();
     }
     if ($savePath) {
         $this->setSavePath($savePath);
     }
     /**
      * Session cache limiter
      */
     $cacheLimiter = $deploymentConfig->get(self::PARAM_SESSION_CACHE_LIMITER);
     if ($cacheLimiter) {
         $this->setOption('session.cache_limiter', $cacheLimiter);
     }
     /**
      * Cookie settings: lifetime, path, domain, httpOnly. These govern settings for the session cookie.
      */
     $this->configureCookieLifetime();
     $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
     $path = empty($path) ? $this->_httpRequest->getBasePath() : $path;
     $this->setCookiePath($path, $this->_httpRequest->getBasePath());
     $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType);
     $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain;
     $this->setCookieDomain((string) $domain, $this->_httpRequest->getHttpHost());
     $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType));
     $secureURL = $this->_scopeConfig->getValue('web/secure/base_url', $this->_scopeType);
     $unsecureURL = $this->_scopeConfig->getValue('web/unsecure/base_url', $this->_scopeType);
     $isFullySecuredURL = $secureURL == $unsecureURL;
     $this->setCookieSecure($isFullySecuredURL && $this->_httpRequest->isSecure());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:54,代码来源:Config.php

示例9: validate

 /**
  * Validate module using curl request
  *
  * @return boolean|array
  */
 public function validate()
 {
     if (!$this->canValidate()) {
         return true;
     }
     $key = trim($this->module->getIdentityKey());
     if (empty($key)) {
         return ['error' => ['Identity key is required']];
     }
     // key format is: encoded_site:secret_key:optional_suffix
     $parts = explode(':', $key);
     if (count($parts) < 3) {
         return ['error' => ['Identity key is not valid']];
     }
     list($site, $secret, $suffix) = explode(':', $key);
     try {
         $client = $this->httpClientFactory->create();
         $client->setUri($this->getUrl($site));
         $client->setConfig(['maxredirects' => 5, 'timeout' => 30]);
         $client->setParameterGet('key', $secret);
         $client->setParameterGet('suffix', $suffix);
         $purchaseCode = $this->module->getRemote()->getPurchaseCode();
         if (!$purchaseCode) {
             $purchaseCode = $this->module->getCode();
         }
         $client->setParameterGet('module', $purchaseCode);
         $client->setParameterGet('module_code', $this->module->getCode());
         if ($this->module->getConfigSection()) {
             $client->setParameterGet('config_section', $this->module->getConfigSection());
         }
         $client->setParameterGet('domain', $this->request->getHttpHost());
         $response = $client->request();
         $responseBody = $response->getBody();
     } catch (\Exception $e) {
         return ['error' => ['Response error: %1', $e->getMessage()], 'response' => $e->getTraceAsString()];
     }
     return $this->parseResponse($responseBody);
 }
开发者ID:swissup,项目名称:core,代码行数:43,代码来源:LicenseValidator.php

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


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