本文整理汇总了PHP中yii\web\Request::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::get方法的具体用法?PHP Request::get怎么用?PHP Request::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Request
的用法示例。
在下文中一共展示了Request::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNoteAuthorId
/**
* @param \yii\web\Request $request
* @return integer|null
*/
private function getNoteAuthorId($request)
{
$noteId = $request->get('id');
/** @var $note Note|null */
$note = Note::findOne($noteId);
return isset($note) ? $note->author_id : null;
}
示例2: respondByJsonFormat
/**
* 输出json
*/
protected function respondByJsonFormat()
{
headers_sent() or header('Content-Type: application/json; charset=utf-8');
$response = json_encode($this->responseData, $this->getJsonEncodeOptions());
if ('' != ($callback = $this->request->get('callback'))) {
$response = $callback . '(' . $response . ');';
}
echo $response;
$this->end();
}
示例3: getRouteFromSlug
/**
* @param \yii\web\Request $request
* @return string
*/
public function getRouteFromSlug($request)
{
$_route = $request->getPathInfo();
$_params = $request->get();
$dbRoute = $this->getRouteFromCacheOrWriteCacheThenRead($_route, $_params);
if (is_object($dbRoute) && $dbRoute->hasAttribute('redirect')) {
if ($dbRoute->getAttribute('redirect')) {
Yii::$app->response->redirect([$dbRoute->slug], $dbRoute->getAttribute('redirect_code'));
}
}
return $_route;
}
示例4: actionView
/**
* Displays product category page.
*
* @param string $path
* @param Request $request
* @return string
* @throws NotFoundHttpException
*/
public function actionView($path, Request $request)
{
$model = $this->findModel($path);
$this->setModel($model);
$categorySearchComponent = $this->getCategorySearchComponent();
$searchableType = 'product';
$searchQuery = $request->get('query', null);
$params['categoriesFacetValueRouteParams'] = function (CategoriesFacetValue $value) {
return ['path' => $value->getEntity()->slug];
};
$dataProvider = $categorySearchComponent->getSearchDataProvider($searchableType, $model, $searchQuery, $params);
$dataProvider->prepare();
$this->_searchResult = $dataProvider->query->result();
return $this->render('view', ['model' => $model, 'productsDataProvider' => $dataProvider]);
}
示例5: actionView
public function actionView($path, Request $request)
{
$model = $this->findModel($path);
/** @var \im\search\components\SearchManager $searchManager */
$searchManager = Yii::$app->get('searchManager');
$query = $request->get('query', '');
$searchComponent = $searchManager->getSearchComponent();
/** @var FacetSet $facetSet */
$facetSet = FacetSet::findOne(1);
$facets = $facetSet->facets;
$query = $searchComponent->getQuery('product', $query, $facets);
$dataProvider = new SearchDataProvider(['query' => $query]);
$dataProvider->prepare();
$this->_searchResult = $dataProvider->query->result();
return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider]);
}
示例6: receive
/**
* @param Request $request
* @return bool
*/
public function receive(Request $request)
{
$this->answer = null;
$model = new IncomingRequest();
if ($model->load($request->get(), '') && $model->validate()) {
$this->sms = $model->toIncomingSms();
$this->sms->save(false);
$this->trigger(self::EVENT_RECEIVE_SMS);
$this->sms->updateAttributes(['answer' => $this->answer]);
$this->isError = false;
return $this;
}
$this->trigger(self::EVENT_ERROR);
$this->isError = true;
return $this;
}
示例7: populateForm
public function populateForm(Request $request)
{
$form = $this->makeForm($request->get('formId'));
$fields = $form->getFields();
foreach ($request->get() as $name => $value) {
$fields[$name]->setValue($value);
}
$this->saveForm($form);
}
示例8: negotiateLanguage
/**
* Negotiates the application language.
* @param Request $request
* @return string the chosen language
*/
protected function negotiateLanguage($request)
{
if (!empty($this->languageParam) && ($language = $request->get($this->languageParam)) !== null) {
if (isset($this->languages[$language])) {
return $this->languages[$language];
}
foreach ($this->languages as $key => $supported) {
if (is_integer($key) && $this->isLanguageSupported($language, $supported)) {
return $supported;
}
}
return reset($this->languages);
}
foreach ($request->getAcceptableLanguages() as $language) {
if (isset($this->languages[$language])) {
return $this->languages[$language];
}
foreach ($this->languages as $key => $supported) {
if (is_integer($key) && $this->isLanguageSupported($language, $supported)) {
return $supported;
}
}
}
return reset($this->languages);
}
示例9: actionManager
public function actionManager(Request $request)
{
return $this->renderFile(__DIR__ . '/views/manager.php', ['options' => $this->getManagerOptions($request->get())]);
}