本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getQuery方法的具体用法?PHP RequestInterface::getQuery怎么用?PHP RequestInterface::getQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentApp
/**
* Get Backend app based on its name
*
* @return BackendApp|null
*/
public function getCurrentApp()
{
$appName = $this->request->getQuery('app');
if ($appName && isset($this->backendApps[$appName])) {
return $this->backendApps[$appName];
}
}
示例2: getSid
/**
* @param SessionManagerInterface $session
* @return string
*/
public function getSid(SessionManagerInterface $session)
{
$sidKey = null;
$useSidOnFrontend = $this->scopeConfig->getValue(self::XML_PATH_USE_FRONTEND_SID, $this->_scopeType);
if ($useSidOnFrontend && $this->request->getQuery($this->getSessionIdQueryParam($session), false) && $this->urlBuilder->isOwnOriginUrl()) {
$sidKey = $this->request->getQuery($this->getSessionIdQueryParam($session));
}
return $sidKey;
}
示例3: testGetSid
/**
* @param mixed $sid
* @param bool $useFrontedSid
* @param bool $isOwnOriginUrl
* @param mixed $testSid
* @dataProvider dataProviderTestGetSid
*/
public function testGetSid($sid, $useFrontedSid, $isOwnOriginUrl, $testSid)
{
$this->scopeConfig->expects($this->any())->method('getValue')->with(\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue($useFrontedSid));
$this->urlBuilder->expects($this->any())->method('isOwnOriginUrl')->will($this->returnValue($isOwnOriginUrl));
if ($testSid) {
$this->request->getQuery()->set($this->model->getSessionIdQueryParam($this->session), $testSid);
}
$this->assertEquals($sid, $this->model->getSid($this->session));
}
示例4: setRouteParams
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function setRouteParams(array $data, $unsetOldParams = true)
{
if (isset($data['_type'])) {
$this->setType($data['_type']);
unset($data['_type']);
}
if (isset($data['_forced_secure'])) {
$this->setSecure((bool) $data['_forced_secure']);
$this->setSecureIsForced(true);
unset($data['_forced_secure']);
} elseif (isset($data['_secure'])) {
$this->setSecure((bool) $data['_secure']);
unset($data['_secure']);
}
if (isset($data['_absolute'])) {
unset($data['_absolute']);
}
if ($unsetOldParams) {
$this->unsetData('route_params');
}
if (isset($data['_current'])) {
if (is_array($data['_current'])) {
foreach ($data['_current'] as $key) {
if (array_key_exists($key, $data) || !$this->request->getUserParam($key)) {
continue;
}
$data[$key] = $this->request->getUserParam($key);
}
} elseif ($data['_current']) {
foreach ($this->request->getUserParams() as $key => $value) {
if (array_key_exists($key, $data) || $this->getRouteParam($key)) {
continue;
}
$data[$key] = $value;
}
foreach ($this->request->getQuery() as $key => $value) {
$this->queryParamsResolver->setQueryParam($key, $value);
}
}
unset($data['_current']);
}
if (isset($data['_use_rewrite'])) {
unset($data['_use_rewrite']);
}
foreach ($data as $key => $value) {
$this->setRouteParam($key, $value);
}
return $this;
}
示例5: setRouteParams
/**
* {@inheritdoc}
*/
public function setRouteParams(array $data, $unsetOldParams = true)
{
if (isset($data['_type'])) {
$this->setType($data['_type']);
unset($data['_type']);
}
if (isset($data['_scope'])) {
$this->setScope($data['_scope']);
unset($data['_scope']);
}
if (isset($data['_forced_secure'])) {
$this->setSecure((bool) $data['_forced_secure']);
$this->setSecureIsForced(true);
unset($data['_forced_secure']);
} elseif (isset($data['_secure'])) {
$this->setSecure((bool) $data['_secure']);
unset($data['_secure']);
}
if (isset($data['_absolute'])) {
unset($data['_absolute']);
}
if ($unsetOldParams) {
$this->unsetData('route_params');
}
if (isset($data['_current'])) {
if (is_array($data['_current'])) {
foreach ($data['_current'] as $key) {
if (array_key_exists($key, $data) || !$this->_request->getUserParam($key)) {
continue;
}
$data[$key] = $this->_request->getUserParam($key);
}
} elseif ($data['_current']) {
foreach ($this->_request->getUserParams() as $key => $value) {
if (array_key_exists($key, $data) || $this->getRouteParam($key)) {
continue;
}
$data[$key] = $value;
}
foreach ($this->_request->getQuery() as $key => $value) {
$this->_queryParamsResolver->setQueryParam($key, $value);
}
}
unset($data['_current']);
}
if (isset($data['_use_rewrite'])) {
unset($data['_use_rewrite']);
}
if (isset($data['_scope_to_url']) && (bool) $data['_scope_to_url'] === true) {
$store = $this->getScope() ?: $this->_storeManager->getStore();
if (!$this->_scopeConfig->getValue(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->getScope()) && !$this->_storeManager->hasSingleStore()) {
$this->_queryParamsResolver->setQueryParam('___store', $store->getCode());
}
}
unset($data['_scope_to_url']);
foreach ($data as $key => $value) {
$this->setRouteParam($key, $value);
}
return $this;
}
示例6: getCurrentUrl
/**
* Retrieve current url for store
*
* @param bool|string $fromStore
* @return string
*/
public function getCurrentUrl($fromStore = true)
{
$sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession());
$requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));
$storeUrl = $this->_storeManager->getStore()->isCurrentlySecure() ? $this->getUrl('', array('_secure' => true)) : $this->getUrl('');
if (!filter_var($storeUrl, FILTER_VALIDATE_URL)) {
return $storeUrl;
}
$storeParsedUrl = parse_url($storeUrl);
$storeParsedQuery = array();
if (isset($storeParsedUrl['query'])) {
parse_str($storeParsedUrl['query'], $storeParsedQuery);
}
$currQuery = $this->_request->getQuery();
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;
}
return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') . $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
}
示例7: testGetScriptOptions
public function testGetScriptOptions()
{
$this->request->getQuery()->set('getparameter', 1);
$this->assertContains('?getparameter=1', $this->javascript->getScriptOptions());
}