-
-
Notifications
You must be signed in to change notification settings - Fork 513
Enable ClassLocator from Doctrine Persistence 4.1 #2802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.12.x
Are you sure you want to change the base?
Conversation
In the scope of doctrine/persistence#432 (available from `doctrine/persistence` >= 4.1) there was added `ColocatedMappingDriver::$filePaths`, which allows passing an `Traversable` of file paths for the mapping driver to use. This commit integrates those changes into `AttributeDriver` (and `AnnotationDriver`). Since `doctrine/orm` maintains the support for `doctrine/persistence` of older versions, the `AttributeDriver` ensures that `$filePaths` is actually defined. Tests use `InstalledVersions` to opt into new behaviour if `doctrine/persistence` is at least version 4.1. The old behaviour can be adapted into new by using `DirectoryFilesIterator` and `FilePathNameIterator` on directory paths.
6388dd8
to
80989af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables ClassLocator support from Doctrine Persistence 4.1, providing more flexible ways to specify document classes for mapping drivers beyond just directory paths. The change allows users to provide class lists or custom locators instead of scanning entire directories.
- Adds support for ClassLocator, ClassNames, and FileClassLocator from Doctrine Persistence 4.1+
- Updates AttributeDriver and AnnotationDriver constructors to accept ClassLocator instances
- Includes backward compatibility checks to work with both old and new versions of Doctrine Persistence
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
lib/Doctrine/ODM/MongoDB/Mapping/Driver/AttributeDriver.php | Adds ClassLocator support and fixes typo in class comment |
lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php | Updates constructor to support ClassLocator and refactors initialization |
tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php | Adds conditional FileClassLocator usage with backward compatibility |
tests/Doctrine/ODM/MongoDB/Tests/Mapping/*.php | Updates test classes to support new ClassLocator functionality |
docs/en/reference/metadata-drivers.rst | Documents new ClassLocator usage patterns and examples |
composer.json | Updates doctrine/persistence dependency to include 4@dev |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Summary
Alternative to #2794 using doctrine/persistence#433