Enhancement
Getting the last counter player, name, or occurrence
Issue description
The Topincs API has the two method familiies get and get_all for getting names, occurrences and counter players. If there is multiple (= maximum cardinality > 1), an occasional demand is to get the last one.
Developer comments
One option would be to add a predefined PHP constant %LAST% and pass it to get. Another would be to add a new method family "last_".
An alternative way to achieve this could be to redefine get_ in this case to return the last one and not the first one, since in most cases you want the last one and not the first one.
Another way would be to equip the iterators with first/last methods.
Equipping the iterators was implemented. It was the easiest and cleanest and still makes it it clear that this is actually an array, so there is more or others, the methods are %first%, %last% and %nth% starting with 1.
As a side note: i noticed that iterating over vast number of occurrences or names is very rare. In most cases it is 1, then there is some occurrence types where there is a handfull up to a dozen, e.g. sending dates of emails. There is never more than 20, except for testing pupposes. For associations there is much broader range.
This works for Tobject::all_ just as well.
|
Work sessions
Start |
2025-03-23T16:12:15
|
End |
2025-03-23T17:21:44
|
Participant |
Robert Cerny
|
|
We are sorry
This page cannot be displayed in your browser. Use Firefox, Opera, Safari, or Chrome instead.