user1929946
user1929946

Reputation: 2503

Mvc, php, symfony 1.4: formatting datas for view, where to put?

Lets imagine this architecture:

model: get record and joined records
controller: iterating through all the records, and doing some calculations, statistics calculations even formatting dates etc
view: show it

is it good? I guess not. But model only may deal with data retrieving - not formatting. Controller cant do that either. Where to do the "iterating through all the records, and doing some calculations, statistics calculations even formatting dates etc" part?

Upvotes: 0

Views: 113

Answers (1)

moonwave99
moonwave99

Reputation: 22810

Framework agnostically speaking:

  • Formatting date is a view helper task usually;

  • If you need calculations [e.g. a mean value of a list], you should define your own collection model, and provide it with methods you'll be using in your application, because there is chance you'd be using them in different controllers, and you don't want to duplicate any code.

Upvotes: 1

Related Questions