本文整理汇总了PHP中Slim\Slim::flashKeep方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::flashKeep方法的具体用法?PHP Slim::flashKeep怎么用?PHP Slim::flashKeep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::flashKeep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureRoutes
/**
* Configure routes to be handled by application.
*
* @param \Slim\Slim $slim Application
*/
protected function configureRoutes(\Slim\Slim $slim)
{
$middleware = array('must-revalidate' => function () use($slim) {
$slim->response->headers->set('Cache-Control', 'private, must-revalidate, max-age=0');
$slim->response->headers->set('Expires', 'Thu, 01 Jan 1970 00:00:00 GMT');
}, 'inject-user' => function () use($slim) {
$user = $slim->authManager->getUserData();
$slim->view->set('user', $user);
}, 'require-user' => function () use($slim) {
if ($slim->authManager->isAnonymous()) {
if ($slim->request->isGet()) {
$uri = $slim->request->getUrl() . $slim->request->getPath();
$qs = Form::qsMerge();
if ($qs) {
$uri = "{$uri}?{$qs}";
}
$_SESSION[AuthManager::NEXTPAGE_SESSION_KEY] = $uri;
}
// FIXME: use i18n
$slim->flash('error', 'Login required');
$slim->flashKeep();
$slim->redirect($slim->urlFor('login'));
}
});
$slim->group('/', $middleware['inject-user'], function () use($slim, $middleware) {
App::redirect($slim, '', 'random', 'home');
App::redirect($slim, 'index', 'random');
$slim->get('random', function () use($slim) {
$page = new Pages\Random($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('random');
$slim->get('random.json', function () use($slim) {
$slim->response->headers->set('Content-Type', 'application/json');
$page = new Pages\Random($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page->setTemplate('random.json');
$page();
})->name('random.json');
$slim->get('search', function () use($slim) {
$page = new Pages\Search($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('search');
$slim->get('top', function () use($slim) {
$page = new Pages\Top($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page();
})->name('top');
App::template($slim, 'login');
$slim->get('logout', $middleware['must-revalidate'], function () use($slim) {
$slim->authManager->logout();
$slim->redirect($slim->urlFor('home'));
})->name('logout');
App::template($slim, 'about');
App::template($slim, 'help');
});
// end group '/'
$slim->group('/quip/', $middleware['inject-user'], function () use($slim, $middleware) {
$slim->get(':id', function ($id) use($slim) {
$page = new Pages\Quip($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('quip');
$slim->get(':id/edit', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Edit($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('edit');
$slim->post(':id/post', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Edit($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('edit_post');
$slim->post(':id/delete', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Delete($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('delete_post');
$slim->post(':id/vote', $middleware['require-user'], function ($id) use($slim) {
$page = new Pages\Vote($slim);
$page->setI18nContext($slim->i18nContext);
$page->setQuips($slim->quips);
$page($id);
})->name('vote_post');
});
$slim->group('/oauth/', function () use($slim) {
//.........这里部分代码省略.........