Reputation: 12704
My application is growing in complexity, and I'm finding that going from ORM entities directly to the view is insufficient.
I want to add models. They will take the data from my ORM entities, but also add some functionality. For example, my User
ORM entity has an endDate
property and a trial
property. I'd like to add an isExpired
method that ensures
endDate
is later than today, andtrial
is false(This is a simple example. My requirements are much more complex, which is why I want to move the logic outside of the view.)
What is the correct way to do this? Say I make a UserModel
class. Will the User
object be a property on that class, in addition to my other properties/methods? Will I be able to preserve Doctrines ability to fetch all objects in a single query?
Upvotes: 3
Views: 130
Reputation: 44851
Why don't you just add the isExpired()
method directly to the entity? No one forces you to keep just the DB stuff in the entities.
Upvotes: 1