Use interfaces for module dependencies

Created on 4 July 2023, 12 months ago

Problem/Motivation

At least one class in the module depends on LoggerChannelFactory, conflicting with contrib modules that extend this class.

Steps to reproduce

1. In a new site install redirect, a contrib module that extends LoggerChannerlFactory and enable the modules

  composer req drupal/redirect drupal/document_ocr 
  drush en redirect redirect_404 document_ocr

2. In the document_ocr settings page (structure, Document OCR) try to add a Processor
3. The action fails, showing this in the logs:

Message	TypeError: Drupal\document_ocr\Plugin\document_ocr\processor\GoogleDocumentAI::__construct(): Argument #6 ($logger_factory) must be of type Drupal\document_ocr\Plugin\document_ocr\processor\LoggerChannelFactoryInterface, Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /app/drupal/docroot/modules/contrib/document_ocr/src/Plugin/document_ocr/processor/GoogleDocumentAI.php on line 55 in Drupal\document_ocr\Plugin\document_ocr\processor\GoogleDocumentAI->__construct() (line 42 of /app/drupal/docroot/modules/contrib/document_ocr/src/Plugin/document_ocr/processor/GoogleDocumentAI.php)

Proposed resolution

Use interfaces for the module dependencies, like LoggerChannelFactoryInterface (instead of LoggerChannelFactory).

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024