I'm developing a CMS largely based on Zend Framework components. Some of the database tables for this CMS are as followed:
site
| id | name |
-------------
locale
| languageCode | regionCode |
-----------------------------
site_locale // link sites with locales
| siteId | languageCode | regionCode | isActive | isDefault |
-------------------------------------------------------------
I have a model named Site
which consists, amongst others, of the following methods:
getId()
getName()
listLocales() // list all locales for this site
I'm kind of on the fence on how granularized I should define models:
One option would be to return SiteLocale
objects/models (in other words a DB table representation) from the listLocales()
method, where these SiteLocale
objects contain the following methods:
getSite() // returns the Site model
getLocale() // returns a Zend_Locale
isActive() // is this locale active for the site this model represents?
isDefault() // is this the default locale for the site this model represents()
The other option would be to simply create the following methods in the Site
model, and be done with it:
getDefaultLocale() // simply return the default site locale as Zend_Locale
listActiveLocales() // simply return all active site locales as Zend_Locales
listAllLocales() // simply return all site locales as Zend_Locales
What do you feel is the right way to go? And why?
Furthermore, would the first option (or perhaps even both options) violate the Law of Demeter?
EDIT (22 jan)
Although I like Jeff's answer, Im still open for new/other perspectives.