當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequestInterface::getRequestString方法代碼示例

本文整理匯總了PHP中Magento\Framework\App\RequestInterface::getRequestString方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestInterface::getRequestString方法的具體用法?PHP RequestInterface::getRequestString怎麽用?PHP RequestInterface::getRequestString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\App\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getRequestString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCurrentUrl

 /**
  * Retrieve current url for store
  *
  * @param bool|string $fromStore
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getCurrentUrl($fromStore = true)
 {
     $sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession());
     $requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));
     $storeUrl = $this->getUrl('', ['_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]);
     if (!filter_var($storeUrl, FILTER_VALIDATE_URL)) {
         return $storeUrl;
     }
     $storeParsedUrl = parse_url($storeUrl);
     $storeParsedQuery = [];
     if (isset($storeParsedUrl['query'])) {
         parse_str($storeParsedUrl['query'], $storeParsedQuery);
     }
     $currQuery = $this->_request->getQueryValue();
     if (isset($currQuery[$sidQueryParam]) && !empty($currQuery[$sidQueryParam]) && $this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]) {
         unset($currQuery[$sidQueryParam]);
     }
     foreach ($currQuery as $key => $value) {
         $storeParsedQuery[$key] = $value;
     }
     if (!$this->isUseStoreInUrl()) {
         $storeParsedQuery['___store'] = $this->getCode();
     }
     if ($fromStore !== false) {
         $storeParsedQuery['___from_store'] = $fromStore === true ? $this->_storeManager->getStore()->getCode() : $fromStore;
     }
     $currentUrl = $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') . $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
     return $currentUrl;
 }
開發者ID:mrbadao,項目名稱:magento-ce,代碼行數:37,代碼來源:Store.php


注:本文中的Magento\Framework\App\RequestInterface::getRequestString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。