忽略二传手注射中缺少的方法

我正在使用PHP特性作为mixin注入可选服务,即

<?php

trait Logger
{
    private LoggerInterface $logger;

    public function getLogger(): LoggerInterface
    {
        return $this->logger;
    }

    /**
     * Inject logger instance (called by the DI container)
     */
    public function setLogger(LoggerInterface $logger): self
    {
        $this->logger = $logger;

        return $this;
    }
}

然后在课堂上使用这个特征:

class UserService
{
    use Logger;
    /* ... */
}

Because this trait can be used in any class, I create a method injection call for all classes in App\ namespace to inject the logger:

App\:
    # ...
    calls:
        - [setLogger, ['@monolog.logger']]

However, when Symfony encounters a service that doesn't implement setLogger method, it throws an error saying 'Invalid service: method "setLogger()" does not exist.'

由于这种注入应该是可选的,如果该方法不存在,是否有办法告诉Symfony忽略该调用?