-
Notifications
You must be signed in to change notification settings - Fork 700
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
EntityToIdObjectTransformer incompatible with doctrine/orm v2.8.X #2302
Comments
This is a huge issue for me and I think for anyone using php >=8 I would really like to leverage some benefits of fos rest, but as of now I do not know how to get |
Does #2306 work for you? |
#2306 fixes the TypeError while using doctrine/orm v2.8.4 for me. However, I still had trouble using the Transformer due to unrelated issues: reverseTransform always returns null due to the value passed never being an array but a string (Past changes in symfony/form break functionality?). Was not able to get it working with a simple test just like the example in the docs (Maybe I’m using it wrong). Should I open an issue for that? I ended up using form field type |
This rather sounds like your use case does not require the transformer at all if the |
Closing as #2306 was merged. |
Issue
The first constructor parameter of class EntityToIdObjectTransformer uses the type declaration
Doctrine\Common\Persistence\ObjectManager
.This causes a TypeError to be thrown when a ObjectManager implementation that uses doctrine/persistence v2.X is passed.
Example
Error message:
Argument 1 passed to FOS\RestBundle\Form\Transformer\EntityToIdObjectTransformer::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given ...
Here Doctrine\ORM\EntityManager implements Doctrine\ORM\EntityManagerInterface which in turn extends Doctrine\Persistence\ObjectManager.
Cause
The doctrine/common package was separated into multiple packages (see doctrine/common#826). Use of the namespace
Doctrine\Common\Persistence
was deprecated and use of the new package namespaceDoctrine\Persistence
encouraged. The backwards compatibility layer for this deprecated namespace was eventually removed in v2.0.0 of doctrine/persistence (see doctrine/persistence#106).Both doctrine/orm v2.8.0 and doctrine/common v3.0.0, switched to version 2 of doctrine/persistence (see doctrine/orm#8166 and doctrine/common#890).
Mitigation
Current mitigation for developers using doctrine/orm and friendsofsymfony/rest-bundle is to restrict the dependencies in their projects as follows:
File composer.json:
The text was updated successfully, but these errors were encountered: