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