本文整理汇总了PHP中yii\web\Request::getQueryParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getQueryParams方法的具体用法?PHP Request::getQueryParams怎么用?PHP Request::getQueryParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Request
的用法示例。
在下文中一共展示了Request::getQueryParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseRequest
/**
* Parses the given request and returns the corresponding route and parameters.
* @param UrlManager $manager the URL manager
* @param Request $request the request component
* @return array|bool the parsing result. The route and the parameters are returned as an array.
* If false, it means this rule cannot be used to parse this path info.
* @throws NotFoundHttpException
*/
public function parseRequest($manager, $request)
{
$this->currentLanguage = Language::getCurrent();
$this->pathInfo = $request->getPathInfo();
if ($this->pathInfo == $this->albumsRoute) {
if ($this->disableDefault) {
throw new NotFoundHttpException();
}
if (!empty($request->getQueryParams()['id'])) {
$id = $request->getQueryParams()['id'];
$album = GalleryAlbum::findOne($id);
if (!$album) {
return false;
}
$translation = $album->getTranslation($this->currentLanguage->id);
if ($translation) {
if (!empty($translation->seoUrl)) {
throw new NotFoundHttpException();
}
}
}
}
if (!empty($this->prefix)) {
if (strpos($this->pathInfo, $this->prefix) === 0) {
$this->pathInfo = substr($this->pathInfo, strlen($this->prefix));
} else {
return false;
}
}
$this->initRoutes($this->pathInfo);
if (!empty($this->prefix) && $this->routesCount == 1) {
return [$this->albumsRoute, []];
} else {
if ($this->routesCount == 2) {
$seoUrl = $this->routes[1];
/* @var SeoData $seoData */
$seoData = SeoData::find()->where(['entity_name' => GalleryAlbumTranslation::className(), 'seo_url' => $seoUrl])->one();
if ($seoData) {
/* @var GalleryAlbum $album */
$album = GalleryAlbum::find()->joinWith('translations translation')->where(['translation.id' => $seoData->entity_id, 'translation.language_id' => $this->currentLanguage->id])->one();
if ($album) {
return [$this->albumsRoute, ['id' => $album->id]];
}
}
}
}
return false;
}
示例2: parseRequest
/**
* Parses the URL and sets the language accordingly
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($request)
{
if ($this->enablePrettyUrl) {
$pathInfo = $request->getPathInfo();
$language = explode('/', $pathInfo)[0];
$locale = ArrayHelper::getValue($this->aliases, $language, $language);
if (in_array($language, $this->languages)) {
$request->setPathInfo(substr_replace($pathInfo, '', 0, strlen($language) + 1));
Yii::$app->language = $locale;
static::$currentLanguage = $language;
}
} else {
$params = $request->getQueryParams();
$route = isset($params[$this->routeParam]) ? $params[$this->routeParam] : '';
if (is_array($route)) {
$route = '';
}
$language = explode('/', $route)[0];
$locale = ArrayHelper::getValue($this->aliases, $language, $language);
if (in_array($language, $this->languages)) {
$route = substr_replace($route, '', 0, strlen($language) + 1);
$params[$this->routeParam] = $route;
$request->setQueryParams($params);
Yii::$app->language = $locale;
static::$currentLanguage = $language;
}
}
return parent::parseRequest($request);
}
示例3: parseRequest
/**
* Parses the given request and returns the corresponding route and parameters.
* @param UrlManager $manager the URL manager
* @param Request $request the request component
* @return array|bool the parsing result. The route and the parameters are returned as an array.
* If false, it means this rule cannot be used to parse this path info.
* @throws NotFoundHttpException
*/
public function parseRequest($manager, $request)
{
$this->currentLanguage = Language::getCurrent();
$this->pathInfo = $request->getPathInfo();
if ($this->pathInfo == $this->categoryRoute || $this->pathInfo == $this->productRoute) {
Yii::$app->urlManager->language = $this->currentLanguage;
if ($this->createUrl(Yii::$app->urlManager, $this->pathInfo, $request->getQueryParams())) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
} else {
if ($this->pathInfo == $this->productRoute && empty($request->getQueryParams()['id'])) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
}
}
}
if (!empty($this->prefix)) {
if (strpos($this->pathInfo, $this->prefix) === 0) {
$this->pathInfo = substr($this->pathInfo, strlen($this->prefix));
} else {
return false;
}
}
$this->initRoutes($this->pathInfo);
if (!empty($this->prefix) && $this->routesCount == 1) {
return [$this->categoryRoute, []];
}
$categoryId = null;
for ($i = 1; $i < $this->routesCount; $i++) {
if ($i === $this->routesCount - 1) {
if ($product = $this->findProductBySeoUrl($this->routes[$i], $categoryId)) {
return ['/' . $this->productRoute, ['id' => $product->id]];
} else {
if ($category = $this->findCategoryBySeoUrl($this->routes[$i], $categoryId)) {
return ['/' . $this->categoryRoute, ['id' => $category->id]];
} else {
return false;
}
}
} else {
if ($category = $this->findCategoryBySeoUrl($this->routes[$i], $categoryId)) {
$categoryId = $category->id;
} else {
return false;
}
}
}
return false;
}
示例4: actionSuccesspay
public function actionSuccesspay()
{
// vd(['get' => Yii::$app->request->getQueryParams() ,
// 'post' => Yii::$app->request->getBodyParams()],1);
$r = new Request();
//Yii::info(\yii\helpers\Json::encode($requestData), 'apiRequest');
\Yii::info('[DEBUG_ME]' . print_r(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], true), 'appDebug');
if ($r->post('action')) {
vd(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], 1);
}
$order = Order::findOne($r->post('orderNumber'));
if ($order) {
} else {
vd($order);
}
$project = $order->project;
return $this->render('successpay', ['project' => $project]);
}
示例5: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
$params = $request->getQueryParams();
$sourceOriginalFile = File::object($pathInfo);
$extension = $sourceOriginalFile->getExtension();
if (!$extension) {
return false;
}
if (Validate::validate(new AllowExtension(), $extension)->isInvalid()) {
return false;
}
return ['cms/imaging/process', $params];
}
示例6: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
$params = $request->getQueryParams();
$sourceOriginalFile = File::object($pathInfo);
$extension = $sourceOriginalFile->getExtension();
if (!$extension) {
return false;
}
if (!in_array(StringHelper::strtolower($extension), (array) \Yii::$app->imaging->extensions)) {
return false;
}
return ['cms/imaging/process', $params];
}
示例7: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
$params = $request->getQueryParams();
$treeNode = null;
if (!$pathInfo) {
return $this->_go();
}
//Если урл преобразован, редирректим по новой
$pathInfoNormal = $this->_normalizeDir($pathInfo);
if ($pathInfo != $pathInfoNormal) {
//\Yii::$app->response->redirect(DIRECTORY_SEPARATOR . $pathInfoNormal . ($params ? '?' . http_build_query($params) : '') );
}
return $this->_go($pathInfoNormal);
}
示例8: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
$params = $request->getQueryParams();
$firstPrefix = substr($pathInfo, 0, strlen($this->adminPrefix));
if ($firstPrefix == $this->adminPrefix) {
$route = str_replace($this->adminPrefix, "", $pathInfo);
if (!$route || $route == "/") {
$route = "admin/index";
}
$params[self::ADMIN_PARAM_NAME] = self::ADMIN_PARAM_VALUE;
return [$route, $params];
//return ["cms/admin-user", $params];
}
return false;
// this rule does not apply
}
示例9: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
$params = $request->getQueryParams();
$treeNode = null;
if (!$pathInfo) {
return false;
}
if (!preg_match('/\\/(?<id>\\d+)\\-(?<code>\\S+)$/i', "/" . $pathInfo, $matches)) {
return false;
}
//Если урл преобразован, редирректим по новой
$pathInfoNormal = $this->_normalizeDir($pathInfo);
if ($pathInfo != $pathInfoNormal) {
//\Yii::$app->response->redirect(DIRECTORY_SEPARATOR . $pathInfoNormal . ($params ? '?' . http_build_query($params) : '') );
}
return ['cms/content-element/view', ['id' => $matches['id'], 'code' => $matches['code']]];
}
示例10: handleRequest
/**
* Handles the specified request.
* @param Request $request the request to be handled
* @return Response the resulting response
* @throws NotFoundHttpException if the requested route is invalid
*/
public function handleRequest($request)
{
if (empty($this->catchAll)) {
try {
list($route, $params) = $request->resolve();
} catch (UrlNormalizerRedirectException $e) {
$url = $e->url;
if (is_array($url)) {
if (isset($url[0])) {
// ensure the route is absolute
$url[0] = '/' . ltrim($url[0], '/');
}
$url += $request->getQueryParams();
}
return $this->getResponse()->redirect(Url::to($url, $e->scheme), $e->statusCode);
}
} else {
$route = $this->catchAll[0];
$params = $this->catchAll;
unset($params[0]);
}
try {
Yii::trace("Route requested: '{$route}'", __METHOD__);
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
} else {
$response = $this->getResponse();
if ($result !== null) {
$response->data = $result;
}
return $response;
}
} catch (InvalidRouteException $e) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
}
}
示例11: redirectToLanguage
/**
* Redirect to the current URL with given language code applied
* @param string $language the language code to add. Can also be empty to not add any language code.
*/
protected function redirectToLanguage($language)
{
$result = parent::parseRequest($this->_request);
if ($result === false) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
}
list($route, $params) = $result;
if ($language) {
$params[$this->languageParam] = $language;
}
$params = $params + $this->_request->getQueryParams();
array_unshift($params, $route);
$url = $this->createUrl($params);
if ($this->suffix === '/' && $route === '') {
$url = rtrim($url, '/') . '/';
}
Yii::$app->getResponse()->redirect($url);
if (YII_ENV_TEST) {
throw new Exception(Url::to($url));
} else {
Yii::$app->end();
}
}
示例12: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
if ($this->mode === self::CREATION_ONLY) {
return false;
}
if (!empty($this->verb) && !in_array($request->getMethod(), $this->verb, true)) {
return false;
}
$pathInfo = $request->getPathInfo();
if ($this->host !== null) {
$pathInfo = strtolower($request->getHostInfo()) . ($pathInfo === '' ? '' : '/' . $pathInfo);
}
$params = $request->getQueryParams();
$suffix = (string) ($this->suffix === null ? $manager->suffix : $this->suffix);
$treeNode = null;
if (!$pathInfo) {
return false;
}
if (!preg_match('/\\/(?<id>\\d+)\\-(?<code>\\S+)$/i', "/" . $pathInfo, $matches)) {
return false;
}
return ['cms/content-element/view', ['id' => $matches['id'], 'code' => $matches['code']]];
}
示例13: parseRequest
/**
* @param \yii\web\UrlManager $manager
* @param \yii\web\Request $request
* @return array|bool
*/
public function parseRequest($manager, $request)
{
if ($this->mode === self::CREATION_ONLY) {
return false;
}
if (!empty($this->verb) && !in_array($request->getMethod(), $this->verb, true)) {
return false;
}
$pathInfo = $request->getPathInfo();
if ($this->host !== null) {
$pathInfo = strtolower($request->getHostInfo()) . ($pathInfo === '' ? '' : '/' . $pathInfo);
}
$params = $request->getQueryParams();
$suffix = (string) ($this->suffix === null ? $manager->suffix : $this->suffix);
$treeNode = null;
$originalDir = $pathInfo;
if ($suffix) {
$originalDir = substr($pathInfo, 0, strlen($pathInfo) - strlen($suffix));
}
$dependency = new TagDependency(['tags' => [(new Tree())->getTableCacheTag()]]);
if (!$pathInfo) {
$treeNode = Tree::getDb()->cache(function ($db) {
return Tree::find()->where(["site_code" => \Yii::$app->cms->site->code, "level" => 0])->one();
}, null, $dependency);
} else {
$treeNode = Tree::find()->where(["dir" => $originalDir, "site_code" => \Yii::$app->cms->site->code])->one();
}
if ($treeNode) {
\Yii::$app->cms->setCurrentTree($treeNode);
$params['id'] = $treeNode->id;
return ['cms/tree/view', $params];
} else {
return false;
}
}
示例14: parseRequest
/**
* Parses the given request and returns the corresponding route and parameters.
* @param \yii\web\UrlManager $manager the URL manager
* @param Request $request the request component
* @return array|bool the parsing result. The route and the parameters are returned as an array.
* @throws ForbiddenHttpException
*/
public function parseRequest($manager, $request)
{
if (!($pathInfo = $request->getPathInfo() or $pathInfo = $this->getMenuMap()->getMainPagePath())) {
return false;
}
//Пункт 2
$this->_activeMenuIds = array_keys($this->getMenuMap()->getLinks(), $request->getUrl());
if ($this->_menu = $this->getMenuMap()->getMenuByPath($pathInfo)) {
//Пункт 1.1
$this->_activeMenuIds[] = $this->_menu->id;
$this->_menu->setContext(MenuItem::CONTEXT_PROPER);
//при полном совпадении метаданные меню перекрывают метаднные контроллера
Yii::$app->getView()->on(View::EVENT_BEGIN_PAGE, [$this, 'applyMetaData']);
} elseif ($this->_menu = $this->getMenuMap()->getApplicableMenuByPath($pathInfo)) {
//Пункт 1.2
$this->_activeMenuIds[] = $this->_menu->id;
$this->_menu->setContext(MenuItem::CONTEXT_APPLICABLE);
$this->applyMetaData();
} else {
return false;
}
// устанавливаем макет приложению
Event::on(Controller::className(), Controller::EVENT_BEFORE_ACTION, [$this, 'applyLayout']);
//Проверка на доступ к пунтку меню
if (!empty($this->_menu->access_rule) && !Yii::$app->user->can($this->_menu->access_rule)) {
if (Yii::$app->user->getIsGuest()) {
Yii::$app->user->loginRequired();
} else {
throw new ForbiddenHttpException(Yii::t('gromver.platform', 'You have no rights for access to this section of the site.'));
}
}
if ($this->_menu->getContext() === MenuItem::CONTEXT_PROPER) {
return $this->_menu->parseUrl();
} else {
$requestRoute = substr($pathInfo, mb_strlen($this->_menu->path) + 1);
list($menuRoute, $menuParams) = $this->_menu->parseUrl();
$requestInfo = new MenuRequest(['menuMap' => $this->getMenuMap(), 'menuRoute' => $menuRoute, 'menuParams' => $menuParams, 'requestRoute' => $requestRoute, 'requestParams' => $request->getQueryParams()]);
foreach ($this->_parseUrlRules as $rule) {
if ($result = $rule->process($requestInfo, $this)) {
return $result;
}
}
return false;
}
}
示例15: load
/**
* Loads query and post params into the model.
* @param ActiveRecord $model
* @param Request $request
* @return bool true if post params were loaded.
*/
protected function load($model, $request)
{
$model->load($request->getQueryParams());
return $model->load($request->getBodyParams());
}