Problem/Motivation
The canvas_bootstrap module's
ThemeAwareSingleDirectoryComponentDiscovery class fails to
instantiate when the canvas module is installed, because its
constructor does not pass a required PropShapeRepositoryInterface
argument when creating the inner
SingleDirectoryComponentDiscovery object.
The canvas module updated
SingleDirectoryComponentDiscovery::__construct() to require
PropShapeRepositoryInterface as its first parameter, but
canvas_bootstrap's ThemeAwareSingleDirectoryComponentDiscovery
was not updated to match. This results in a fatal error at runtime when
the canvas component discovery service is resolved from the container.
Steps to reproduce
- Install both
drupal/canvasanddrupal/canvas_bootstrap. - Enable both modules.
- Visit any page that triggers the canvas component plugin manager (e.g. a
page using a layout with canvas components, or by clearing caches). - Observe a fatal PHP error:
Too few arguments to function SingleDirectoryComponentDiscovery::__construct()
(or anArgumentCountError/ type mismatch depending on PHP version).
Proposed resolution
Update ThemeAwareSingleDirectoryComponentDiscovery to:
- Add
use Drupal\canvas\PropShape\PropShapeRepositoryInterface;to the imports. - Inject
PropShapeRepositoryInterfaceas the first constructor argument (matching the updatedSingleDirectoryComponentDiscoverysignature). - Pass
$this->propShapeRepositoryas the first argument when constructing the innerSingleDirectoryComponentDiscoveryinstance. - Resolve
PropShapeRepositoryInterface::classfrom the container in thecreate()factory method.
Remaining tasks
- Review and commit the patch.
- Add a regression test that verifies the service can be instantiated
when bothcanvasandcanvas_bootstrapare enabled.
User interface changes
None.
API changes
The constructor signature of
ThemeAwareSingleDirectoryComponentDiscovery gains a new required
first parameter: PropShapeRepositoryInterface $propShapeRepository.
Any code instantiating this class directly (outside the container) will
need to be updated to pass this argument.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | canvas_bootstrap-constructor-fix.patch | 1.38 KB | alabandit |
Issue fork canvas_bootstrap-3605189
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alabandit commentedComment #6
ahmad abbad commentedComment #8
ahmad abbad commentedThank you, alabandit
Comment #9
ahmad abbad commented