The Drupal\file_extractor\Service\ExtractorManager service no longer receives the logger.channel.file_extractor logger as a constructor argument. It now implements \Psr\Log\LoggerAwareInterface and uses \Psr\Log\LoggerAwareTrait, so the logger is set automatically through setter injection (see Loggers can be autoconfigured for service classes implementing LoggerAwareInterface). To enable this, the module's services now use autoconfigure: true.
The $logger argument was removed from the constructor, so every argument after it moves up one position.
Before
public function __construct(
protected ConfigFactoryInterface $configFactory,
protected ExtractorPluginManager $extractorPluginManager,
#[Autowire(service: 'logger.channel.file_extractor')]
protected LoggerInterface $logger,
#[Autowire(service: 'file.mime_type.guesser')]
protected MimeTypeGuesserInterface $mimeTypeGuesser,
protected EventDispatcherInterface $eventDispatcher,
#[Autowire(service: 'cache.file_extractor')]
protected CacheBackendInterface $cacheBackend,
)
After
class ExtractorManager implements ExtractorManagerInterface, LoggerAwareInterface {
use LoggerAwareTrait;
public function __construct(
protected ConfigFactoryInterface $configFactory,
protected ExtractorPluginManager $extractorPluginManager,
#[Autowire(service: 'file.mime_type.guesser')]
protected MimeTypeGuesserInterface $mimeTypeGuesser,
protected EventDispatcherInterface $eventDispatcher,
#[Autowire(service: 'cache.file_extractor')]
protected CacheBackendInterface $cacheBackend,
) {}
Who is affected
Only code that extends ExtractorManager and overrides or calls its constructor, or that creates it directly with new. Code that gets the service from the container or depends on ExtractorManagerInterface does not need any change.
How to update
Remove the logger argument from your constructor and from any parent::__construct() call. If you create the class yourself (for example in a unit test), call setLogger() after creating it:
$manager = new ExtractorManager($config_factory, $plugin_manager, $mime_type_guesser, $event_dispatcher, $cache_backend);
$manager->setLogger($logger);
If you override the service definition with your own class, enable autoconfigure: true on it (and keep implementing LoggerAwareInterface). Otherwise, add a setLogger method call yourself:
calls:
- [setLogger, ['@logger.channel.file_extractor']]
Because the logger is now set through a setter, $this->logger can be NULL before setLogger() is called. Subclasses should use $this->logger?->....
AI disclosure
Generated with the help of an LLM.