2016-09-15 13:03 GMT+02:00 Marcel de Rooy <m.de.r...@rijksmuseum.nl>: > Hi devs, >
Hi :) > I am seeing more Koha objects that include methods for related records like > Koha::Patron, sub image referring to Koha::Patron::Images. > > As a second example, on bug 14610 (article requests), a biblio, item, branch > and borrower method is added to Koha::ArticleRequest. These methods should highlight the relationships (fk or missing fk at DB level) between objects. They make sense to me as long as we want to manipulate Koha::Objects. Note that branch should be replaced with library ;) > Obviously, they all follow the same pattern. > > Could we generalize that, and keep our code cleaner? > > > > And do we always need the full Koha object? For use in a template we may > need only a few columns. What do you suggest? It's much easier to always get and pass a full object than sometimes a smaller one without knowing exactly what it represents (which methods you can call on it). I don't think it will hurt perfs too much. Of course there will certainly be some rooms for improvements here, it should not be a rule written in stone. > We start passing these objects to the templates now too, making it possible > to call methods from the template. It is possible, but do we really want > that? More code ends up in the template, maybe harder to find since you now > use borrower.method instead of borrower->method etc. Secondly, reading > borrower.something might not immediately tell you that something is a method > instead of a column. Yes, I don't think it's a good thing. We should avoid calling methods in template, only accessors. If the method is trivial, I'd say it could be ok. > In other cases we have added a sort of wrapper like Branches.GetName from > the Branches plugin. That was to help us, and that will continue to help us, because the fk don't always exist. If should not hurt perf neither. > I am interested to know if we want to enforce this wrapper approach for > instance, or just continue on the current road. Where and why? :) Usually I don't think TT plugins should be used for such things. In an ideal world, we would manipulate objects in templates and library.branchname would display the library name (in a ideal world it would be library.name...). Or patron.library.branchname, but we should not need a plugin for that: Branches.GetName( patron.branchcode ) Cheers > Thx, > > > > Marcel > > > > > _______________________________________________ > Koha-devel mailing list > Koha-devel@lists.koha-community.org > http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel > website : http://www.koha-community.org/ > git : http://git.koha-community.org/ > bugs : http://bugs.koha-community.org/ _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/