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
Serializer and Validator mappings don't use Bundle#getPath() #18563
Comments
👍 Same here, forced to use the default location. @wouterj How would you access the bundle class instance in a compiler pass? |
I think one of my colleagues hit this bump when trying to register virtual bundles. |
If I understand the issue correctly, the problem lies with the Bundle files being meta information and functional at the same time. |
To clarify; this is also not about moving things from extensions to compilers (it could be legit though) as in both cases there's no context/service object/kernel/whatsoever available. Extensions are just part of a compiler. |
See #21113 |
…ndles with custom structure (chalasr) This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle][HttpKernel] Fix resources loading for bundles with custom structure | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18563 | License | MIT | Doc PR | n/a This fixes twig/translator/validator/serializer resource loading for bundles overriding `Bundle::getPath()`, adding a kernel parameter containing the bundle metadata (i.e. `path`, `namespace` and `parent`). Fixes #18563 and unlocks #19586 Commits ------- fef3146 Fix serializer/translations/validator resources loading for bundles overriding getPath()
Description
The bundle class has a
getPath()
method, allowing you to override the path of the bundle. However, inside the FrameworkExtension,$reflection->getFileName()
is used to get the path to the bundle. This means thatgetPath()
is ignored.Use-case
In my case, my bundle directory structure looks like:
In the
MyBundle
class, I overridegetPath()
to returnMyBundle/
. This way, I would expect the serializer and validator configuration to be loaded. However, since they use reflection they're looking forMyBundle/src/Resources/config/serializer.yml
.Possible Solution
The auto-discovery of config files should be moved to a compiler pass. These have access to the bundle class instance (instead of FQCN) and can call
->getPath()
on this instance instead of simulating the default behaviour of this method.The text was updated successfully, but these errors were encountered: