Closed silverbackdan closed 2 years ago
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
I can't remember, but I did have this solution in place so I have not felt the need to revisit it.
Let's close here for now then and we can consider to reopen once some comes back with the same problem. Thank you for the feedback @silverbackdan!
Description The services 'serializer.mapping.chain_loader' and 'serializer.mapping.cache_warmer' both call the
ClassMetadataFactory::getMetadataFor
method with their own loaders in the constructor arguments. It'd be preferable for the chain_loader constructor arguments to be used in the cache_warmer, or for the ClassMetadata not to be generated again.Example I have a compiler pass that looks like this
I have to populate my additional loaders into the constructor argument of both services. Otherwise the cache_warmer will override the metadata in production only. So the behaviour in dev and production differs.
Do you think it'd be worth passing the chain loader as a service to the cache warmer perhaps to share the metadata that's already been generated?
I only raise this because it took a little while for me to work out why this was happening. In production, if I did not add the loaders to the cache warmer, then if I specified any annotation or yaml configuration for a PHP class, it'd override the metadata instead of merging it.