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


PHP RequestInterface::getDistroBaseUrl方法代码示例

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


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

示例1: testGetDistroBaseUrl

 /**
  * @param $serverVariables array
  * @param $expectedResult string
  * @dataProvider serverVariablesProvider
  */
 public function testGetDistroBaseUrl($serverVariables, $expectedResult)
 {
     $originalServerValue = $_SERVER;
     $_SERVER = $serverVariables;
     $this->assertEquals($expectedResult, $this->_model->getDistroBaseUrl());
     $_SERVER = $originalServerValue;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:HttpTest.php

示例2: install

 /**
  * Generate installation data and record them into local.xml using local.xml.template
  *
  * @return void
  */
 public function install()
 {
     $data = $this->getConfigData();
     $defaults = array('root_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR), 'app_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::APP_DIR), 'var_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR), 'base_url' => $this->_request->getDistroBaseUrl());
     foreach ($defaults as $index => $value) {
         if (!isset($data[$index])) {
             $data[$index] = $value;
         }
     }
     if (isset($data['unsecure_base_url'])) {
         $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : '';
         if (strpos($data['unsecure_base_url'], 'http') !== 0) {
             $data['unsecure_base_url'] = 'http://' . $data['unsecure_base_url'];
         }
         if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) {
             $this->_checkUrl($data['unsecure_base_url']);
         }
     }
     if (isset($data['secure_base_url'])) {
         $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : '';
         if (strpos($data['secure_base_url'], 'http') !== 0) {
             $data['secure_base_url'] = 'https://' . $data['secure_base_url'];
         }
         if (!empty($data['use_secure']) && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) {
             $this->_checkUrl($data['secure_base_url']);
         }
     }
     $data['date'] = self::TMP_INSTALL_DATE_VALUE;
     $data['key'] = self::TMP_ENCRYPT_KEY_VALUE;
     $data['var_dir'] = $data['root_dir'] . '/var';
     $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false';
     $this->_getInstaller()->getDataModel()->setConfigData($data);
     $contents = $this->_configDirectory->readFile('local.xml.template');
     foreach ($data as $index => $value) {
         $contents = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $contents);
     }
     $this->_configDirectory->writeFile($this->_localConfigFile, $contents);
     $this->_configDirectory->changePermissions($this->_localConfigFile, 0777);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:44,代码来源:Config.php

示例3: _processPlaceholders

 /**
  * Replace placeholders with config values
  *
  * @param string $value
  * @param array $data
  * @return string
  */
 protected function _processPlaceholders($value, $data)
 {
     $placeholder = $this->_getPlaceholder($value);
     if ($placeholder) {
         $url = false;
         if ($placeholder == 'unsecure_base_url') {
             $url = $this->_getValue($this->urlPaths['unsecureBaseUrl'], $data);
         } elseif ($placeholder == 'secure_base_url') {
             $url = $this->_getValue($this->urlPaths['secureBaseUrl'], $data);
         }
         if ($url) {
             $value = str_replace('{{' . $placeholder . '}}', $url, $value);
         } elseif (strpos($value, $this->urlPlaceholder) !== false) {
             $distroBaseUrl = $this->request->getDistroBaseUrl();
             $value = str_replace($this->urlPlaceholder, $distroBaseUrl, $value);
         }
         if (null !== $this->_getPlaceholder($value)) {
             $value = $this->_processPlaceholders($value, $data);
         }
     }
     return $value;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:Placeholder.php

示例4: getBaseUrl

 /**
  * Retrieve base URL
  *
  * @param string $type
  * @param boolean|null $secure
  * @return string
  * @throws \InvalidArgumentException
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getBaseUrl($type = UrlInterface::URL_TYPE_LINK, $secure = null)
 {
     $cacheKey = $type . '/' . ($secure === null ? 'null' : ($secure ? 'true' : 'false'));
     if (!isset($this->_baseUrlCache[$cacheKey])) {
         $secure = $secure === null ? $this->isCurrentlySecure() : (bool) $secure;
         switch ($type) {
             case UrlInterface::URL_TYPE_WEB:
                 $path = $secure ? self::XML_PATH_SECURE_BASE_URL : self::XML_PATH_UNSECURE_BASE_URL;
                 $url = $this->getConfig($path);
                 break;
             case UrlInterface::URL_TYPE_LINK:
                 $path = $secure ? self::XML_PATH_SECURE_BASE_LINK_URL : self::XML_PATH_UNSECURE_BASE_LINK_URL;
                 $url = $this->getConfig($path);
                 $url = $this->_updatePathUseRewrites($url);
                 $url = $this->_updatePathUseStoreView($url);
                 break;
             case UrlInterface::URL_TYPE_DIRECT_LINK:
                 $path = $secure ? self::XML_PATH_SECURE_BASE_LINK_URL : self::XML_PATH_UNSECURE_BASE_LINK_URL;
                 $url = $this->getConfig($path);
                 $url = $this->_updatePathUseRewrites($url);
                 break;
             case UrlInterface::URL_TYPE_STATIC:
                 $path = $secure ? self::XML_PATH_SECURE_BASE_STATIC_URL : self::XML_PATH_UNSECURE_BASE_STATIC_URL;
                 $url = $this->getConfig($path);
                 if (!$url) {
                     $url = $this->getBaseUrl(UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(DirectoryList::STATIC_VIEW);
                 }
                 break;
             case UrlInterface::URL_TYPE_MEDIA:
                 $url = $this->_getMediaScriptUrl($this->filesystem, $secure);
                 if (!$url) {
                     $path = $secure ? self::XML_PATH_SECURE_BASE_MEDIA_URL : self::XML_PATH_UNSECURE_BASE_MEDIA_URL;
                     $url = $this->getConfig($path);
                     if (!$url) {
                         $url = $this->getBaseUrl(UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(DirectoryList::MEDIA);
                     }
                 }
                 break;
             default:
                 throw new \InvalidArgumentException('Invalid base url type');
         }
         if (false !== strpos($url, self::BASE_URL_PLACEHOLDER)) {
             $url = str_replace(self::BASE_URL_PLACEHOLDER, $this->_request->getDistroBaseUrl(), $url);
         }
         $this->_baseUrlCache[$cacheKey] = rtrim($url, '/') . '/';
     }
     return $this->_baseUrlCache[$cacheKey];
 }
开发者ID:mrbadao,项目名称:magento-ce,代码行数:59,代码来源:Store.php


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