當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Slim::flashKeep方法代碼示例

本文整理匯總了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) {
//.........這裏部分代碼省略.........
開發者ID:bd808,項目名稱:quips,代碼行數:101,代碼來源:App.php


注:本文中的Slim\Slim::flashKeep方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。