Skip to content

Commit 3148eed

Browse files
committed
Fix example app deprecation warnings with Symfony 2.2
1 parent c39ac31 commit 3148eed

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": ">=5.3.3",
2323
"guzzle/http": "3.*",
24-
"symfony/http-foundation": "2.*"
24+
"symfony/http-foundation": "~2.0"
2525
},
2626
"require-dev": {
2727
"guzzle/plugin-mock": "3.*",

example/index.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@
2121
// enable Silex debugging
2222
$app['debug'] = true;
2323

24-
// twig globals
25-
$app->before( function() use ( $app ) {
26-
$notice = $app['session']->getFlash('notice');
27-
if ($notice) {
28-
$app['twig']->addGlobal('notice', $notice);
29-
}
30-
});
31-
3224
// root route
3325
$app->get('/', function() use ($app) {
3426
$gateways = array_map(function($name) {
@@ -62,7 +54,7 @@
6254
$app['session']->set($sessionVar, $gateway->getParameters());
6355

6456
// redirect back to gateway settings page
65-
$app['session']->setFlash('success', 'Gateway settings updated!');
57+
$app['session']->getFlashBag()->add('success', 'Gateway settings updated!');
6658

6759
return $app->redirect($app['request']->getPathInfo());
6860
});

example/views/layout.twig

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99
<div class="container">
1010
<h1>{{ title }}</h1>
1111

12-
{% set success = app.session.flash('success') %}
13-
{% set error = app.session.flash('error') %}
14-
{% if success %}
15-
<div class="alert alert-success">{{ success }}</div>
16-
{% endif %}
17-
{% if error %}
18-
<div class="alert alert-error">{{ error }}</div>
19-
{% endif %}
12+
{% for message in app.session.flashbag.get('success') %}
13+
<div class="alert alert-success">{{ message }}</div>
14+
{% endfor %}
2015

2116
{% block content %}{% endblock %}
2217
</div>

0 commit comments

Comments
 (0)