-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[DoctrineBridge] add support for ClassLocator
#61538
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
[DoctrineBridge] add support for ClassLocator
#61538
Conversation
1b5a0c6 to
ad2b74b
Compare
GromNaN
left a comment
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.
For the moment, I don't see what functionality it brings to the users. Is the idea to overload the $driverName.'_mapping_class_finder' service with custom constraints?
src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
Show resolved
Hide resolved
| $finderService = $this->getObjectManagerElementName($driverName.'_mapping_class_finder'); | ||
|
|
||
| if ($container->hasDefinition($finderService)) { | ||
| $finderDefinition = $container->getDefinition($finderService); |
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.
If the service has already be declared in the application, it should not be modified. Otherwise I fail to see the purpose of customizing this service.
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.
It's necessary to make in($dirs) call to give context of where to look for the files.
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.
If in([$dirs]) is forced, there's no real freedom to configure the finder. You have to mix the bundle configuration and your custom finder definition.
Instead of creating a service definition named $driverName.'_mapping_class_finder', I suggest you directly inject a definition as an argument to $driverName.'_mapping_class_locator', it is then necessary to define a full ClassLocator service, or replace its first argument if necessary.
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.
Let's wait for your changes; maybe this PR won't be necessary at all
Yes, that's the main point. The second point is about the future deprecation of |
ad2b74b to
13a8910
Compare
In the scope of doctrine/persistence#433 (available from `doctrine/persistence` >= 4.1) there was added `ColocatedMappingDriver::$classLocator`, which allows passing any instance of `ClassLocator` for the mapping driver to use. This commit integrates those changes into `AbstractDoctrineExtension`, used by respective ORM, MongoDB-ODM, PHPCR-ODM bundles. The solution registers a "mapping_class_finder" service that can be used by the client code to customize class finding logic. The changes come into play starting with doctrine/persistence >= 4.1, and the actual registration happens only if `AttributeDriver` supports `ClassLocator`. Dependent libraries would adhere to the same interface, where `ClassLocator` is in the first argument. The changes were introduced for: - ORM: doctrine/orm#12131; - ODM: doctrine/mongodb-odm#2802; - PHPCR ODM: doctrine/phpcr-odm#875.
13a8910 to
9c126d4
Compare
|
The |
|
The |
This PR introduces support for
ClassLocator, added to Persistence in doctrine/persistence#433, integrated into ORM in doctrine/orm#12131, and ODM doctrine/mongodb-odm#2802.The new
AttributeDrivercan now acceptClassLocatorinstead of$pathsarray:The PR introduces a new
ClassLocatorservice$driverName.'_mapping_class_locator'that will be used in theAttributeDriver.Also it registers
Finderservice$driverName.'_mapping_class_finder'that is needed for the locator to operate:This is an otherwise identical
Finder-based alternative forFileClassLocator::createFromDirectories().The changes opt in if the installed ORM/ODM libraries support it (
doctrine/persistence >= 4.1,doctrine/orm >= 3.6,doctrine/mongodb-odm >= 2.12).Replacing the
arrayargument in$mappingDriverDefwithnew Reference($classLocator)could be considered a Breaking Change, since one could've modified the array of paths afterwards; however, it's unlikely that anybody used a Compiler Pass to modify it - GitHub search found no occurrences of it.