Allow the mapped event subscriber to use an attribute reader by default #2713
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.
This is building off the conversation in #2683 as a way to try and decouple the hard
doctrine/annotations
dependency inGedmo\Mapping\MappedEventSubscriber
. Whenever any of the extension listener classes don't have a reader injected through thesetAnnotationReader()
method, this base class will callGedmo\Mapping\MappedEventSubscriber::getDefaultAnnotationReader()
and create a basic annotation reader. With the announced intent to deprecate thedoctrine/annotations
package, this is a step in helping to break the hard dependency here by introducing a new fallback behavior ifdoctrine/annotations
isn't installed (right now it's a hard dependency to this package so these new fallbacks won't be hit at all yet, hence this being a WIP PR with time to discuss it).For B/C, it will continue to default to creating an annotation reader first. It then falls back to creating an attribute reader if running PHP 8, then will hard fail if neither option is available.
A reader still needs to always be created for now as the
$annotationReader
argument for theGedmo\Mapping\ExtensionMetadataFactory
class constructor requires a reader, the logic in the subscriber'sgetDefaultAnnotationReader()
method can be revisited when this hard requirement is addressed (as the factory only needs a reader if it creates aGedmo\Mapping\Driver\AnnotationDriverInterface
orGedmo\Mapping\Driver\AttributeDriverInterface
instance; XML or (deprecated) YAML drivers do not need this reader).