Closed distantnative closed 3 years ago
IMO It doesn't duplicate, but it looks like code that does the same thing a little differently. Just the source they loop in is different but I think it can be combined as well.
True.
One is setting translations only if any have been passed to the constructor (setTranslations
).
The other one sets them if none have been set so far/via the constructor (translations
).
@bastianallgeier Did we split this for performance reasons? e.g. if none are passed to the constructor, only set them if ->translations()
is even called
They both need to exist.
setTranslations is used when you create virtual pages for example. In this case each translation is an array of props.
The translations getter is loading translations from kirby->languages() if they are not set yet and each translation is a language object.
I don't see how we could improve this a lot without making it more complex.
Seems like both methods are almost doing the same thing. Why have we implemented this in two different methods?