Unable to inject serializer service in parent abstract class in symfony 4.4

290 Views Asked by At

I'm just trying to inject the symfony serializer into an abstract class constructor, but that does not seem to work at all :

namespace App\DTO;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;

abstract class AbstractDTOMapper
{
    protected Serializer $serializer;

    public function __construct(SerializerInterface $serializer)
    {
        $this->serializer = $serializer;
    }

And that is the config in services.yaml:

  App\DTO\AbstractDTOMapper:
    abstract: true
    arguments:
      - '@serializer'

I still get this error :

Too few arguments to function App\DTO\AbstractDTOMapper::__construct(), 0 passed in C:\Users\me\Documents\project\src\Entity\Common\User.php on line 296 and exactly 1 expected
0

There are 0 best solutions below