Task #34912
Models with a 's' at the end getting wierd
| Status: | Closed | Start date: | 2012-03-16 | |
|---|---|---|---|---|
| Priority: | Won't have this time | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Code Creation | |||
| Target version: | - | |||
| Votes: | 0 |
Description
Hi,
Imagine a model "News", then the list action will state
1 public function listAction() {
2 $newss = $this->newsRepository->findAll();
3 $this->view->assign('newss', $newss);
4 }
$newss is really strange, maybe if ends with 's', leave it that way?
History
Updated by Nico de Haen about 1 year ago
That's a limitation of the DDD approach to have "speaking" model and variable names.
To avoid duplicate variable declarations we can't do:
<for each="news" as="news">
The additional "s" is added by purpose. It works in most cases where a word can't be pluralized. (Like peoples => people).
Any idea for a better solution?
Updated by Georg Ringer about 1 year ago
true, not really better would be to have $newsItems which would then only be strange when having $itemItems ;) or $newsObjects, or better $newsCollection?
Updated by Nico de Haen about 1 year ago
Collection would not be bad, but that's a breaking change then and since the generated stuff is just "to start with" I would prefer to leave it as it is.
Updated by Steffen Müller about 1 year ago
OT: A chance to rename the model from news to article ;-)
Updated by Roland Waldner about 1 year ago
what about defining singular and plural of an objects name in the extension builder - two seperate input fields - both would be obligatory and both must not be equal. so the extension developer would automatically be forced to find appropriate names.
Updated by Nico de Haen 12 months ago
- Status changed from New to Closed
- Priority changed from Could have to Won't have this time
I think we won't integrate this, since we didn't find a proper solution