class PrefetchHelper (View source)

This helper collects information about what nodes will be loaded when creating a document proxy and allows to load them in one go, even for a collection.

The trick is to gather as many paths and UUID as possible to fetch them in a single call. Once the transport cached them, we can use normal PHPCR calls to access them, keeping the code readable.

Methods

prefetch(DocumentManagerInterface $dm, $nodes, $locale = null)

No description

prefetchReferences(ClassMetadata $class, NodeInterface $node)

Prefetch all mapped ReferenceOne annotations.

prefetchHierarchy(ClassMetadata $class, NodeInterface $node, string|null $locale = null)

Prefetch all Child mappings and the ParentDocument if annotations exist.

array
collectPrefetchReferences(ClassMetadata $class, NodeInterface $node)

Gather all UUIDs to pre-fetch nodes in MANY_TO_ONE mappings.

array
collectPrefetchHierarchy(ClassMetadata $class, NodeInterface $node, string|null $locale = null)

Gather the parent and all child mappings so they can be fetched in one go.

Details

prefetch(DocumentManagerInterface $dm, $nodes, $locale = null)

Parameters

DocumentManagerInterface $dm
$nodes
$locale

prefetchReferences(ClassMetadata $class, NodeInterface $node)

Prefetch all mapped ReferenceOne annotations.

Parameters

ClassMetadata $class The metadata about the document to know what to do.
NodeInterface $node The node to prefetch parent and childs for.

prefetchHierarchy(ClassMetadata $class, NodeInterface $node, string|null $locale = null)

Prefetch all Child mappings and the ParentDocument if annotations exist.

Parameters

ClassMetadata $class The metadata about the document to know what to do.
NodeInterface $node The node to prefetch parent and childs for.
string|null $locale The locale to also prefetch the translation child if applicable.

array collectPrefetchReferences(ClassMetadata $class, NodeInterface $node)

Gather all UUIDs to pre-fetch nodes in MANY_TO_ONE mappings.

Parameters

ClassMetadata $class The metadata about the document to know what to do.
NodeInterface $node The node to prefetch parent and childs for.

Return Value

array List of UUID to fetch in one go.

array collectPrefetchHierarchy(ClassMetadata $class, NodeInterface $node, string|null $locale = null)

Gather the parent and all child mappings so they can be fetched in one go.

Parameters

ClassMetadata $class The metadata about the document to know what to do.
NodeInterface $node The node to prefetch parent and childs for.
string|null $locale The locale to also prefetch the translation child if applicable.

Return Value

array List of absolute paths to nodes that should be prefetched.