Repository navigation
Decide what the hydrator does once per class with handlers - #224
Closed
DanielBadura wants to merge 2 commits into
Closed
DanielBadura wants to merge 2 commits into
DanielBadura wants to merge 2 commits into
Conversation
The StackHydrator keeps a handler per class and direction: the transformer itself if nothing else has to run, otherwise a handler which calls the class normalizer, runs the middlewares or creates a lazy proxy. The middleware chain is built once per class and reused. Transformer factories get a TransformerResolver, the ReflectionTransformer uses it to map nested objects with the handlers of their classes directly instead of going through the ObjectNormalizer and the hydrator again.
|
Hello 👋 here is the most recent benchmark result:
This comment gets update everytime a new commit comes in! |
The handlers and the transformer described the same thing: what runs for a class in one direction. The resolver returned either of them, so the hydrator and the transformers had to tell them apart, and the handler and transformer namespaces depended on each other. Now there is one concept per direction. A ClassHydrator hydrates the objects of one class from an array, a ClassExtractor extracts them. The ClassTransformer is both and the end of the chain the hydrator builds per class, every middleware and the lazy proxy wrap the rest of the chain. If nothing else runs, the transformer is the whole chain. A middleware gets the rest of the chain as $next and calls it with the data and the context, Next is removed. A class with a class normalizer has no chain, the hydrator calls the normalizer and the resolver returns null.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The StackHydrator injected itself into every HydratorAwareNormalizer of the
loaded metadata. That mutated shared, cached metadata and made it hard for a
hydrator which wraps the StackHydrator to see nested objects. The hydrator is
now passed with every call in the context under Hydrator::HYDRATOR. Each
hydrator only sets it if it is missing, so the outermost one wins.
HydratorAwareNormalizer and the setHydrator() methods of the built-in
normalizers are removed.