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


PHP Application::addFlash方法代碼示例

本文整理匯總了PHP中Silex\Application::addFlash方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::addFlash方法的具體用法?PHP Application::addFlash怎麽用?PHP Application::addFlash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Silex\Application的用法示例。


在下文中一共展示了Application::addFlash方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

 public function delete(Application $app, Request $request, $id)
 {
     $repo = $app->getRepository($this->getModelName());
     try {
         $repo->remove($repo->find($id));
     } catch (PDOException $e) {
         $app->addFlash('error', $e->getMessage());
     }
     // @todo Check errors
     return $app->redirect($app['url_generator']->generate(sprintf('%s_index', $this->getModelName())));
 }
開發者ID:radvance,項目名稱:radvance,代碼行數:11,代碼來源:CrudControllerTrait.php

示例2: connect

 public function connect(SilexApplication $app)
 {
     $app['controller.lightbox'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->before(function (Request $request) use($app) {
         if (!$request->query->has('LOG')) {
             return;
         }
         if ($app['authentication']->isAuthenticated()) {
             $app['authentication']->closeAccount();
         }
         if (null === ($token = $app['repo.tokens']->findValidToken($request->query->get('LOG')))) {
             $app->addFlash('error', $app->trans('The URL you used is out of date, please login'));
             return $app->redirectPath('homepage');
         }
         $app['authentication']->openAccount($token->getUser());
         switch ($token->getType()) {
             case TokenManipulator::TYPE_FEED_ENTRY:
                 return $app->redirectPath('lightbox_feed_entry', ['entry_id' => $token->getData()]);
                 break;
             case TokenManipulator::TYPE_VALIDATE:
             case TokenManipulator::TYPE_VIEW:
                 return $app->redirectPath('lightbox_validation', ['basket' => $token->getData()]);
                 break;
         }
     });
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before($app['middleware.basket.converter'])->before($app['middleware.basket.user-access']);
     $controllers->get('/', function (SilexApplication $app) {
         try {
             \Session_Logger::updateClientInfos($app, 6);
         } catch (SessionNotFound $e) {
             return $app->redirectPath('logout');
         }
         $repository = $app['repo.baskets'];
         $basket_collection = array_merge($repository->findActiveByUser($app['authentication']->getUser()), $repository->findActiveValidationByUser($app['authentication']->getUser()));
         $template = 'lightbox/index.html.twig';
         if (!$app['browser']->isNewGeneration() && !$app['browser']->isMobile()) {
             $template = 'lightbox/IE6/index.html.twig';
         }
         return new Response($app['twig']->render($template, ['baskets_collection' => $basket_collection, 'module_name' => 'Lightbox', 'module' => 'lightbox']));
     })->bind('lightbox');
     $controllers->get('/ajax/NOTE_FORM/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) {
         if (!$app['browser']->isMobile()) {
             return new Response('');
         }
         $basketElement = $app['repo.basket-elements']->findUserElement($sselcont_id, $app['authentication']->getUser());
         $parameters = ['basket_element' => $basketElement, 'module_name' => ''];
         return $app['twig']->render('lightbox/note_form.html.twig', $parameters);
     })->bind('lightbox_ajax_note_form')->assert('sselcont_id', '\\d+');
     $controllers->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) {
         $repository = $app['repo.basket-elements'];
         $BasketElement = $repository->findUserElement($sselcont_id, $app['authentication']->getUser());
         if ($app['browser']->isMobile()) {
             $output = $app['twig']->render('lightbox/basket_element.html.twig', ['basket_element' => $BasketElement, 'module_name' => $BasketElement->getRecord($app)->get_title()]);
             return new Response($output);
         } else {
             $template_options = 'lightbox/sc_options_box.html.twig';
             $template_agreement = 'lightbox/agreement_box.html.twig';
             $template_selector = 'lightbox/selector_box.html.twig';
             $template_note = 'lightbox/sc_note.html.twig';
             $template_preview = 'common/preview.html.twig';
             $template_caption = 'common/caption.html.twig';
             if (!$app['browser']->isNewGeneration()) {
                 $template_options = 'lightbox/IE6/sc_options_box.html.twig';
                 $template_agreement = 'lightbox/IE6/agreement_box.html.twig';
             }
             $Basket = $BasketElement->getBasket();
             $ret = [];
             $ret['number'] = $BasketElement->getRecord($app)->get_number();
             $ret['title'] = $BasketElement->getRecord($app)->get_title();
             $ret['preview'] = $app['twig']->render($template_preview, ['record' => $BasketElement->getRecord($app), 'not_wrapped' => true]);
             $ret['options_html'] = $app['twig']->render($template_options, ['basket_element' => $BasketElement]);
             $ret['agreement_html'] = $app['twig']->render($template_agreement, ['basket' => $Basket, 'basket_element' => $BasketElement]);
             $ret['selector_html'] = $app['twig']->render($template_selector, ['basket_element' => $BasketElement]);
             $ret['note_html'] = $app['twig']->render($template_note, ['basket_element' => $BasketElement]);
             $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $BasketElement->getRecord($app)]);
             return $app->json($ret);
         }
     })->bind('lightbox_ajax_load_basketelement')->assert('sselcont_id', '\\d+');
     $controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function (SilexApplication $app, $entry_id, $item_id) {
         $entry = $app['repo.feed-entries']->find($entry_id);
         $item = $entry->getItem($item_id);
         if ($app['browser']->isMobile()) {
             $output = $app['twig']->render('lightbox/feed_element.html.twig', ['feed_element' => $item, 'module_name' => $item->getRecord($app)->get_title()]);
             return new Response($output);
         } else {
             $template_options = 'lightbox/feed_options_box.html.twig';
             $template_preview = 'common/preview.html.twig';
             $template_caption = 'common/caption.html.twig';
             if (!$app['browser']->isNewGeneration()) {
                 $template_options = 'lightbox/IE6/feed_options_box.html.twig';
             }
             $ret = [];
             $ret['number'] = $item->getRecord($app)->get_number();
             $ret['title'] = $item->getRecord($app)->get_title();
             $ret['preview'] = $app['twig']->render($template_preview, ['record' => $item->getRecord($app), 'not_wrapped' => true]);
             $ret['options_html'] = $app['twig']->render($template_options, ['feed_element' => $item]);
             $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $item->getRecord($app)]);
             $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = '';
//.........這裏部分代碼省略.........
開發者ID:nlegoff,項目名稱:Phraseanet,代碼行數:101,代碼來源:Lightbox.php

示例3: displayResetEmailForm

 /**
  * Display reset email form
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function displayResetEmailForm(Application $app, Request $request)
 {
     if (null !== ($token = $request->query->get('token'))) {
         try {
             $datas = $app['tokens']->helloToken($token);
             $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id']);
             $user->setEmail($datas['datas']);
             $app['tokens']->removeToken($token);
             $app->addFlash('success', $app->trans('admin::compte-utilisateur: L\'email a correctement ete mis a jour'));
             return $app->redirectPath('account');
         } catch (\Exception $e) {
             $app->addFlash('error', $app->trans('admin::compte-utilisateur: erreur lors de la mise a jour'));
             return $app->redirectPath('account');
         }
     }
     return $app['twig']->render('account/reset-email.html.twig', Login::getDefaultTemplateVariables($app));
 }
開發者ID:romainneutron,項目名稱:Phraseanet,代碼行數:24,代碼來源:Account.php

示例4: displayResetEmailForm

 /**
  * Display reset email form
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function displayResetEmailForm(Application $app, Request $request)
 {
     if (null !== ($tokenValue = $request->query->get('token'))) {
         if (null === ($token = $app['repo.tokens']->findValidToken($tokenValue))) {
             $app->addFlash('error', $app->trans('admin::compte-utilisateur: erreur lors de la mise a jour'));
             return $app->redirectPath('account');
         }
         $user = $token->getUser();
         $user->setEmail($token->getData());
         $app['manipulator.token']->delete($token);
         $app->addFlash('success', $app->trans('admin::compte-utilisateur: L\'email a correctement ete mis a jour'));
         return $app->redirectPath('account');
     }
     return $app['twig']->render('account/reset-email.html.twig', Login::getDefaultTemplateVariables($app));
 }
開發者ID:nlegoff,項目名稱:Phraseanet,代碼行數:22,代碼來源:Account.php


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