I'm using Symfony 5.4 as REST API.
I would like to override this class :(Symfony\Component\Security\Core\Exception\BadCredentialsException)
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Core\Exception;
/**
* BadCredentialsException is thrown when the user credentials are invalid.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander <iam.asm89@gmail.com>
*/
class BadCredentialsException extends AuthenticationException
{
/**
* {@inheritdoc}
*/
public function getMessageKey()
{
return 'Invalid credentials.';
}
}
By my custom class :
<?php
declare(strict_types=1);
namespace App\Exception;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class BadCredentialsException extends AuthenticationException
{
/**
* {@inheritdoc}
*/
public function getMessageKey()
{
return 'Invalid custom message';
}
}
I think the best way is to use a decorator but i can't achieve that.
Thank you for your help