Problem/Motivation
On a site with both UI Patterns and Canvas installed, applying any recipe fails with:
TypeError: Drupal\canvas\PropShape\PropShape::componentPluginManager(): Return value must be of type Drupal\canvas\Plugin\ComponentPluginManager, Drupal\ui_patterns\ComponentPluginManager returned
Canvas sets the class of plugin.manager.sdc to its own ComponentPluginManager and aliases Drupal\canvas\Plugin\ComponentPluginManager to that service. UI Patterns decorates plugin.manager.sdc and stays outermost (decoration_priority -100), so that alias resolves to the UI Patterns manager, which is not of the class Canvas is typed against.
The error is thrown from the Canvas RecipeSubscriber::onApply, so on such a site every recipe apply fails, including the Drupal CMS recipes.
Steps to reproduce
- Install a site with both drupal/canvas and drupal/ui_patterns enabled.
- Apply any recipe, for example
drush recipe recipes/some_recipe. - The apply stops with the TypeError above.
Proposed resolution
Register a compiler pass from UiPatternsServiceProvider, only when the canvas module is present, that re-points the Drupal\canvas\Plugin\ComponentPluginManager alias to Drupal\ui_patterns\ComponentPluginManager.inner, the Canvas classed manager UI Patterns already decorates, and makes it public. plugin.manager.sdc stays the UI Patterns manager.
AI-Generated: Yes
Issue fork ui_patterns-3623504
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 #3
dalemoore commentedIs this not the same issue as https://www.drupal.org/project/ui_patterns/issues/3551586#comment-16593229? If so I think they fixed it mostly on UI Patterns side, it's Canvas side that still needs fixing.
Comment #4
rajab natshahI'm facing the issue with Drupal Canvas 1.11.0 the latest release
Comment #5
rajab natshahI thought the fix could be in Canvas, but it is easier to integrate with Canvas, than getting a fix in Drupal Canvas
Comment #6
just_like_good_vibesHello,
thank you for raising this error.
Indeed, getting interoperability with Canvas seems not easy to get, despite raising the hand already a long time ago #3552818: Contrib compatibility: ComponentPluginManager decorator should call decorated service instead of parent.
We have also a recent ui_patterns issue #3619953: Update service injections to use lowermost class, permitting further downstream extensions of SDC dealing with interoperability of contrib modules and the decoration of sdc plugin manager. i started to work on that already.
About the current issue and its proposed solution, let's remark that in ui_patterns we don't have dependencies or mentions of contrib space. The current MR is adding a reference to "canvas", so we need to think twice before merging such a dependency outside core.
By the way, we need a bold move in ui_patterns, to cope with both the current issue and #3619953: Update service injections to use lowermost class, permitting further downstream extensions of SDC,
that would be immediately compatible with current canvas code but also the future when #3552818: Contrib compatibility: ComponentPluginManager decorator should call decorated service instead of parent would be finally merged.
Allowing both modules installed would be a first step, but we need to verify there won't be further problems about mutual understanding of sdc components definitions (i.e. schema).
Comment #7
rajab natshahGot that, Mikael
I'm trying only to have them required in the same project .. but not to enable canvas
It is building of a Display Builder + UI Patterns ) Site templates .. but to allow to be installed by the Drupal CMS Installer
testing that with
drupal/website_starteras it dose not use Canvas at all, but only uses UI Pattern with Display Builder.I managed to having them working with
drupal/websiteproject template but not withdrupal/cmsComment #8
just_like_good_vibesHello rajab,
thank you for taking the time to report and propose some code.
After some discussions with other maintainers, some tests and some tries,
we are proposing a bigger evolution of ui_patterns to cope with canvas but also with other decorators of the sdc plugin manager.
would you have time to try the work done in #3625036: Read component definitions from our own service, not from plugin.manager.sdc please ? please make the comments directly in the other issue.
thank you very much
Comment #9
just_like_good_vibesComment #10
just_like_good_vibesComment #11
just_like_good_vibesHello, we have merged #3625036: Read component definitions from our own service, not from plugin.manager.sdc. Can you check that it fixes the current issue please (it should).
please test without display_builder activated, to allow also display_builder with canvas see the follow-up #3625330: [UI Patterns 2.0.22] Use new plugin.manager.ui_patterns_component service