I want to override a class from the JMS/serializer bundle. Unfortunately this class is marked "final" and I can't override it. What would be the best method to circumvent this problem please? I'm on symfony5.4
Here is the class I want to override :
<?php
declare(strict_types=1);
namespace JMS\Serializer\Handler;
use JMS\Serializer\GraphNavigatorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use JMS\Serializer\XmlSerializationVisitor;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface as TranslatorContract;
use function get_class;
final class FormErrorHandler implements SubscribingHandlerInterface
{
/**
* @var TranslatorInterface|null
*/
private $translator;
/**
* @var string
*/
private $translationDomain;
I finally found a solution. I overridden the FormErrorHandler class from FOS/SerializerbUndle and then I overridden the formErrorHandlere class from JMS which I call in my overload of FOS/FormErrorHandler. it works perfectly