Problem/Motivation
The settings page at /admin/config/user-interface/printable fails with HTTP 500 when the plugin.manager.block service is decorated. Drupal Canvas does this out of the box (Drupal\canvas\Block\BlockManagerDecorator), so every site that uses Canvas and Printable cannot open the Printable settings form.
PrintableConfigurationForm::__construct() type-hints the concrete Drupal\Core\Block\BlockManager class. A decorator implements Drupal\Core\Block\BlockManagerInterface but is not a BlockManager, so PHP throws:

TypeError: Drupal\printable\Form\PrintableConfigurationForm::__construct(): Argument #3 ($blockManager) must be of type Drupal\Core\Block\BlockManager, Drupal\canvas\Block\BlockManagerDecorator given, called in modules/contrib/printable/src/Form/PrintableConfigurationForm.php on line 44

The form only calls clearCachedDefinitions() on the block manager, which is available on the interface. This is the same kind of problem fixed for PdfFormat in #3317347.

Steps to reproduce
1.Drupal 11.3 site with Printable 3.1.4 (also present on 3.x-dev) and Drupal Canvas 1.x enabled. Any other module that decorates plugin.manager.block triggers the same error.
2.Log in as an administrator.
3.Visit /admin/config/user-interface/printable.
4.The page returns HTTP 500 and the TypeError above is logged. The other Printable settings pages (e.g. /admin/config/user-interface/printable/pdf) and the printable output itself keep working

Proposed resolution
Type-hint Drupal\Core\Block\BlockManagerInterface instead of Drupal\Core\Block\BlockManager in PrintableConfigurationForm (use statement, constructor parameter and docblock). Patch attached.
Tested on Drupal 11.3 with Canvas 1.8: the settings form loads, saves without errors, and printable/PDF output is unchanged.

Comments

vasil.vasilev@jakala created an issue. See original summary.

vasil.vasilev@jakala’s picture

Issue summary: View changes
vasil.vasilev@jakala’s picture

Issue summary: View changes
vasil.vasilev@jakala’s picture

Issue summary: View changes
vasil.vasilev@jakala’s picture

Issue summary: View changes