Configuring a ZF2 view helper before rendering – Rob Allen's DevNotes


: 4

The currencyFormat view helper is very easy to use:

When I was reading the documentation for the currencyFormat view helper, I discovered that you could configure the currency code and locale once rather than in every call:

This is obviously useful, but even more useful would be if we could set it once by default and then override if we need to in a specific call.

The easiest way to do this is to use an event listener on the View event within a modules's onBootstrap method, like this:

Now we can simply do call currencyFormat() with the value in our view script: