-
Notifications
You must be signed in to change notification settings - Fork 2
How it works
Collections themselves don't actually need translating - but the models they hold do. Because of this, the collection transformer doesn't do much other than try and retrieve translations for all models in the fastest way possible. This means building a ResourceCriteria object that holds the criteria necessary to execute just one query within the repository.
Once the translations have been found, it will then apply these translations to all models (handled by the model transformer) and returns the collection, which has now been transformed into a translated collection object.
It's possible (and desirable) in many cases to translate and transform a single model. This model may also contain it's own eagerly loaded relationships, with its collection of models as well. As a result, model transformation can actually end up doing quite a bit, passing back and forth between the model and collection transformers to create the translated entity objects that are eventually returned.
The important thing to note is that all of this is done as quickly as possible, with just one query - for all nested models and collections. The package does this by doing two passes over the nested collections and models. The first pass collects all the resources needed for the query. The second pass then grabs the results from the query and applies it to each of the models and collections.
-
Home
- Objectives of this package
- [Who this package is for](Who this package is for)
- [Working with the Translator](Working with the Translator)
- [How it works](How it works)