Download the PHP package barthy-koeln/cached-prezent-translation without Composer
On this page you can find all versions of the php package barthy-koeln/cached-prezent-translation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download barthy-koeln/cached-prezent-translation
More information about barthy-koeln/cached-prezent-translation
Files in barthy-koeln/cached-prezent-translation
Package cached-prezent-translation
Short Description Provides a trait to be used with prezent/translatable-bundle
License MIT
Homepage https://github.com/BarthyB/cached-prezent-translation
Informations about the package cached-prezent-translation
Cached Translation
This library provides a simple trait that can be used with the prezent/doctrine-translatable-bundle
.
This is mostly a copy-pasted php trait from the prezent/doctrine-translatable
docs about proxy getters and setters, adapted for php >= 7.4 and opinionated code styles.
The trait stores the current locale, fallback locale, and caches the last fetched translation.
Usually, only one translation is necessary for an app: the current locale's translation or the fallback translation.
Since prezent/translatable-bundle
uses FETCH_EXTRA_LAZY
,
the cached translation does not trigger any additional straight SELECT statements if queried from the object multiple times.
In a situation where more than one translation is needed (i.e. multiple translations must be loaded for the application, it is best to either manually fully initialise the collection or to handle caching yourself.
Installation
Usage
Entity
``