For a specific entry in a specific section I would like to eager load all associated data from the related elements.
Say that I know the related elements are from the following field types:
- An assets field
- An entries field
And I know the field handles or IDs. This isn't supposed to be a "catch all" solution, it can be on a case by case basis.
I want to eagerly load all of these elements (including their relationships should they have some, i.e., the related entries have related images).
How would I go about this in a plugin?
I know I can write a hook or a custom controller action, I'm more curious about how I'd setup the calls themselves. I can't use Yii's
with for Active Record because that isn't setup in the entry record itself.
Note, this is similar to the following question, but more direct: "Eager loading" of relations like Yii's "with" function