Fosrestbundle: Type error

Created on 30 Aug 2018  路  5Comments  路  Source: FriendsOfSymfony/FOSRestBundle

TypeError: Argument 1 passed to FOS\RestBundle\Serializer\Normalizer\FormErrorHandler::__construct() must be an instance of JMS\Serializer\Handler\FormErrorHandler, instance of Symfony\Component\Translation\IdentityTranslator

Most helpful comment

Hello, so from version 2.4 how is the correct way to override the FormErrorHandler? I used to override the parameter jms_serializer.form_error_handler.class.

All 5 comments

Can you add some description on how we can reproduce your issue?

I have FosRestBunde and JMSSerializerBundle integrated by replace jms_serializer.form_error_handler.class by FOS\RestBundle\Serializer\Normalizer\FormErrorHandler.

My config.yml file:

parameters:
    jms_serializer.form_error_handler.class: FOS\RestBundle\Serializer\Normalizer\FormErrorHandler

This commit https://github.com/FriendsOfSymfony/FOSRestBundle/commit/096e47142da33a0d706e5a6c5562dd039293c0c3#diff-2f2dd8f9f89d6a2ae93756480b5cc6f3
changed FOS\RestBundle\Serializer\Normalizer\FormErrorHandler constructor from TranslatorInterface to JMSFormErrorHandler.

Here is service definition https://github.com/schmittjoh/JMSSerializerBundle/blob/master/Resources/config/services.xml with translator service as agrument

After remove class replacement: jms_serializer.form_error_handler.class: FOS\RestBundle\Serializer\Normalizer\FormErrorHandler bug dissapear

Yeah, using the class parameter is not the way this class is supposed to be used. In fact, I don't think you should have to worry about it at all as the service should be registered by the bundle for you already. I am closing here as there is no bug.

Hello, so from version 2.4 how is the correct way to override the FormErrorHandler? I used to override the parameter jms_serializer.form_error_handler.class.

I have exactly the same issue. What is the proper way to make small modifications to FormErrorHandler after 2.4?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gnucki picture Gnucki  路  7Comments

matrix818181 picture matrix818181  路  7Comments

MissbachMichael picture MissbachMichael  路  7Comments

soullivaneuh picture soullivaneuh  路  5Comments

JeroenDeDauw picture JeroenDeDauw  路  6Comments