I'm a PHP Developer, and I'm working with Symfony2 at the moment.
I would like to present my issue as follow:
- I have 4 entities: User, Account, Customer, Merchant. All of them have status.
- I want to build a common method named 'isValid' for them, but don't want to modify their code.
-
The method logic is very simple
public function isValid() { return self::STATUS_ACTIVE == $this->status; }
- By separate them and apply a HAS-A relation between it with entities, i think it will more flexible and maintainable. I don't have to duplicate my code to any entity need it, even in the future.
If you have experience. Could you please help me to pick a suitable pattern for this situation?
Aucun commentaire:
Enregistrer un commentaire