本文整理汇总了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())));
}
示例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'] = '';
//.........这里部分代码省略.........
示例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));
}
示例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));
}