Konrad Podgórski Web Developer / Software Architect

Place where I used to write about code related things. Currently umaintained.

Method "getFlashes" for object "Symfony\Component\HttpFoundation\Session\Session" does not exist

Please keep in mind that this post was written more than 2 years ago and might be outdated.

Quick reference for people upgrading Symfony

Error

Method "getFlashes" for object "Symfony\Component\HttpFoundation\Session\Session" does not exist

Change

app.session.getFlashes()

to

app.session.get('flashes')

Before

    {% for key, message in app.session.getFlashes() %}
    <div class="alert alert-{{ key }}" style="margin-top: 3px;">
        <a class="close" data-dismiss="alert">×</a>
        <strong>{{ ('alert_message.' ~ key)|trans }}</strong> {{ message }}
    </div>
    {% endfor %}

After change

    {% for key, message in app.session.get('flashes') %}
    <div class="alert alert-{{ key }}">
        <a class="close" data-dismiss="alert">×</a>
        <strong>{{ ('alert_message.' ~ key) | trans }}</strong> {{ message | trans }}
    </div>
    {% endfor %}

That's it

on

Find this post helpful? Spread the word, thanks.

Comments