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


PHP RequestInterface::getBasePath方法代码示例

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


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

示例1: __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

示例2: getCookiePath

 /**
  * Get session.cookie_path
  *
  * @return string
  */
 public function getCookiePath()
 {
     if (!$this->hasOption('session.cookie_path')) {
         $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
         if (empty($path)) {
             $path = $this->_httpRequest->getBasePath();
         }
         $this->setCookiePath($path);
     }
     return (string) $this->getOption('session.cookie_path');
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:16,代码来源:Config.php

示例3: __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

示例4: __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


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