Skip to content

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

Open
wants to merge 6 commits into
base: 2.12.x
Choose a base branch
from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Aug 13, 2025

Q A
Type feature
BC Break no
Fixed issues

Summary

Alternative to #2794 using doctrine/persistence#433

@GromNaN GromNaN marked this pull request as draft August 13, 2025 14:37
@GromNaN GromNaN requested a review from Copilot August 13, 2025 14:37
Copilot

This comment was marked as outdated.

rela589n and others added 4 commits August 22, 2025 01:01
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.
@GromNaN GromNaN force-pushed the class-locator branch 3 times, most recently from 6388dd8 to 80989af Compare August 21, 2025 23:50
@GromNaN GromNaN marked this pull request as ready for review August 21, 2025 23:51
@GromNaN GromNaN requested review from Copilot and greg0ire August 21, 2025 23:51
Copy link

@Copilot Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants