本文整理汇总了PHP中yii\helpers\Url::remember方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::remember方法的具体用法?PHP Url::remember怎么用?PHP Url::remember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Url
的用法示例。
在下文中一共展示了Url::remember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDetails
public function actionDetails($id)
{
// Нужен для возврата на страницу после логина
// Возможно делается как-то проще
Url::remember();
$trainingMatch = TrainingMatch::find()->with('greenPlayers', 'purplePlayers', 'refusedPlayers')->with(['greenPlayers.playerStars' => function ($query) use($id) {
$query->where(['training_match_id' => $id]);
}, 'purplePlayers.playerStars' => function ($query) use($id) {
$query->where(['training_match_id' => $id]);
}])->where(['id' => $id])->orderBy('')->asArray()->one();
// Merge all players
// accepted or refused current match
$players = array_merge($trainingMatch['greenPlayers'], $trainingMatch['purplePlayers'], $trainingMatch['refusedPlayers']);
$playerIds = array_map(function ($player) {
return $player['id'];
}, $players);
// Other players
$otherPlayers = Player::find()->with('playerStatisticSummary')->where(['not in', 'id', $playerIds])->all();
// Sort players by games count
usort($otherPlayers, function ($a, $b) {
return $b['playerStatisticSummary']['count_games'] - $a['playerStatisticSummary']['count_games'];
});
$matchTimestamp = strtotime($trainingMatch['date_time']);
return $this->render('details', ['trainingMatch' => $trainingMatch, 'otherPlayers' => $otherPlayers, 'weather' => WeatherService::getWeather($matchTimestamp)]);
}
示例2: actionIndex
/**
* Lists all Book models.
* @return mixed
*/
public function actionIndex()
{
Url::remember(Url::current(), 'books');
$searchModel = new BookSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例3: actionList
/**
* @return string
*/
public function actionList()
{
Url::remember(Url::current(), self::REMEMBER_NAME);
$this->getView()->addBread('List');
$searchPrice = new SearchPrice();
return $this->render('list', ['searchPrice' => $searchPrice]);
}
示例4: actionUpdateProfile
public function actionUpdateProfile($id)
{
\yii\helpers\Url::remember('', 'actions-redirect');
$user = $this->findModel($id);
$profile = \backend\models\Profile::findOne(['user_id' => $user->id]);
if ($profile == null) {
$profile = Yii::createObject(\backend\models\Profile::className());
$profile->link('user', $user);
}
$this->performAjaxValidation($profile);
if ($profile->load(Yii::$app->request->post())) {
$profile->fileProfile = \yii\web\UploadedFile::getInstance($profile, 'fileProfile');
$save_fileProfile = '';
if ($profile->fileProfile) {
$imagepath = 'uploads/profile/';
// Create folder under web/uploads/logo
$profile->image_profile = $imagepath . rand(10, 100) . '-' . $profile->fileProfile->name;
$save_fileProfile = 1;
}
if ($profile->save()) {
if ($save_fileProfile) {
$profile->fileProfile->saveAs($profile->image_profile);
} else {
echo 'ada yang salah';
}
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Profile details have been updated'));
return $this->refresh();
}
}
return $this->render('_profile', ['user' => $user, 'profile' => $profile]);
}
示例5: actionIndex
/**
* Lists all Employee models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new EmployeeSearch();
$dataProvider = $searchModel->search(isset($_GET['q']) ? $_GET['q'] : null);
Url::remember();
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例6: run
public function run()
{
Url::remember('', $this->generateKey());
// create temporary file
$model = $this->_model;
$twigCode = $model ? $model->value : null;
$tmpFile = \Yii::getAlias('@runtime') . '/' . md5($twigCode);
file_put_contents($tmpFile, $twigCode);
$render = new ViewRenderer();
try {
$html = $render->render('renderer.twig', $tmpFile, []);
} catch (\Twig_Error $e) {
\Yii::$app->session->addFlash('warning', $e->getMessage());
$html = '';
}
if (\Yii::$app->user->can(self::ACCESS_ROLE)) {
$link = Html::a('prototype module', $model ? $this->generateEditRoute($model->id) : $this->generateCreateRoute());
if ($this->enableFlash) {
\Yii::$app->session->addFlash($html ? 'success' : 'info', "Edit contents in {$link}, key: <code>{$this->generateKey()}</code>");
}
if (!$model && $this->renderEmpty) {
$html = $this->renderEmpty();
}
}
\Yii::trace('Twig widget rendered', __METHOD__);
return $html;
}
示例7: actionIndex
public function actionIndex()
{
Url::remember('', 'actions-redirect');
$searchModel = Yii::createObject(UserSearch::className());
$dataProvider = $searchModel->search(Yii::$app->request->get());
return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
}
示例8: actionPage
/**
* renders a page view from the database
*
* @param $id
* @param null $pageName
* @param null $parentLeave
*
* @return string
* @throws HttpException
*/
public function actionPage($id, $pageName = null, $parentLeave = null)
{
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
// Set layout
$this->layout = '@app/views/layouts/main';
// Get active Tree object, allow access to invisible pages
// @todo: improve handling, using also roles
$pageQuery = Tree::find()->where([Tree::ATTR_ID => $id, Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_ACCESS_DOMAIN => \Yii::$app->language]);
// Show disabled pages for admins
if (!\Yii::$app->user->can('pages')) {
$pageQuery->andWhere([Tree::ATTR_DISABLED => Tree::NOT_DISABLED]);
}
// get page
$page = $pageQuery->one();
if ($page !== null) {
// Set page title
$this->view->title = $page->page_title;
// Register default SEO meta tags
$this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords]);
$this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description]);
if (\Yii::$app->user->isGuest) {
Yii::$app->response->headers->set('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', time() + (getenv("HTTP_EXPIRES") !== null ? getenv("HTTP_EXPIRES") : 0)));
}
// Render view
return $this->render($page->view, ['page' => $page]);
} else {
throw new HttpException(404, \Yii::t('app', 'Page not found.') . ' [ID: ' . $id . ']');
}
}
示例9: run
public function run()
{
$model = new Comments();
if (!is_string($this->model)) {
$model->post_id = $this->model->getPrimaryKey();
$model->module = get_class($this->model);
$order = '';
} else {
$model->post_id = 0;
$model->module = $this->model;
$order = 'DESC';
}
// Получаем комментарии этого модуля и пост айди
$models = Comments::getComments($model->module, $model->post_id, $order);
// Получаем кол-во страниц комментариев для редиректа
$page = $models['pages']->totalCount / $models['pages']->pageSize + 1;
if ($model->load(Yii::$app->request->post())) {
if ($model->save()) {
Url::remember(Url::current());
Yii::$app->getSession()->setFlash('success', '<i class="fa fa-check fa-1x"></i> Good! ');
if (!is_string($this->model)) {
return Yii::$app->getResponse()->redirect('/post/' . $this->model->slug . '/' . $model->post_id . '?page=' . round($page) . '#' . $model->id);
} else {
return Yii::$app->getResponse()->refresh();
}
}
}
return $this->render('widgetComment', ['model' => $model, 'models' => $models['models'], 'pages' => $models['pages'], 'options' => $this->options]);
}
示例10: actionIndex
/**
* Lists all User models.
* @return mixed
*/
public function actionIndex()
{
Url::remember(Yii::$app->getRequest()->getUrl());
$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例11: actionIndex
/**
* Lists all RedirectUrl models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new RedirectUrlSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Url::remember();
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
示例12: actionIndex
/**
* Lists all Model models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new Search();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Url::remember(Url::to(''), static::FILTERED_LINK_KEY);
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authorsAssoc' => \app\models\authors\Model::getAllAsAssoc()]);
}
示例13: actionView
/**
* Shows information about Payment.
*
* @param int $id
*
* @return string
*/
public function actionView($id)
{
Url::remember('', 'actions-redirect');
$payment = $this->findModel($id);
$itemsDp = new ActiveDataProvider(['query' => $payment->getItems()]);
return $this->render('view', ['model' => $payment, 'itemsDp' => $itemsDp]);
}
示例14: actionMatrix
public function actionMatrix()
{
$this->sidebar = ['parent' => 'sidebar-identity', 'child' => 'matrix'];
// Remember return url for crud
Url::remember(['permission/matrix'], 'roles');
return parent::actionMatrix(CoreGlobal::TYPE_SYSTEM);
}
示例15: actionPage
/**
* renders a page view from the database.
*
* @param $pageId
* @param null $pageName
* @param null $parentLeave
*
* @return string
*
* @throws HttpException
*/
public function actionPage($pageId, $pageName = null, $parentLeave = null)
{
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
// Set layout
$this->layout = '@app/views/layouts/main';
// Get active Tree object, allow access to invisible pages
// @todo: improve handling, using also roles
$pageQuery = Tree::find()->where([Tree::ATTR_ID => $pageId, Tree::ATTR_ACTIVE => Tree::ACTIVE, Tree::ATTR_ACCESS_DOMAIN => \Yii::$app->language]);
// Show disabled pages for admins
if (!\Yii::$app->user->can('pages')) {
$pageQuery->andWhere([Tree::ATTR_DISABLED => Tree::NOT_DISABLED]);
}
// get page
$page = $pageQuery->one();
if ($page !== null) {
// Set page title, use name as fallback
$this->view->title = $page->page_title ?: $page->name;
// Register default SEO meta tags
$this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords]);
$this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description]);
// Render view
return $this->render($page->view, ['page' => $page]);
} else {
if ($fallbackPage = $this->resolveFallbackPage($pageId)) {
\Yii::trace('Resolved fallback URL for ' . $fallbackPage->id, __METHOD__);
return $this->redirect($fallbackPage->createUrl(['language' => $fallbackPage->access_domain]));
} else {
throw new HttpException(404, \Yii::t('pages', 'Page not found.') . ' [ID: ' . $pageId . ']');
}
}
}