Problem/Motivation
SDC components have a group property: https://api.drupal.org/api/drupal/core%21modules%21sdc%21src%21Component...
But it doesn't seem this property is leveraged until now.
Proposed resolution
Implement CategorizingPluginManagerInterface in ComponentPluginManager:
It may not be possible to use CategorizingPluginManagerTrait because the property is group instead of category.
User interface changes
No. Some contrib modules can leverage the added methods to build UI widgets, but nothing will happen in Core in the scope of this ticket.
API changes
Only additions, so not breaking.
Release notes snippet
"ComponentPluginManager is implementing CategorizingPluginManagerInterface"
Issue fork drupal-3474533
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
pdureau commentedI will try to propose a MR.
Comment #3
pdureau commentedComment #4
wim leersLooking forward to an MR to review! 🤓
Comment #5
pdureau commentedIf you wish, you can have a look on an existing and well tested implementation of this interface for SDC plugin manager: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Componen...
Comment #6
vensiresComment #8
vensiresImplemented the changes required in the MR. Please review.
Comment #9
wim leersOne test failed:
Comment #10
vensiresComment #12
longwaveRebased, LayoutSectionTest passed locally for me so perhaps an unrelated random fail, let's see what happens on CI.
Comment #14
longwaveAlternatively why can't we just add
categoryas the trait requires, and copy it fromgroupwith a default? See MR!10245.Comment #15
longwaveAssigning to Wim for review.
Comment #16
wim leers#14: interesting alternative! And very pragmatic 👏
Just one nit: I think the default
groupshould be defined in\Drupal\Core\Theme\ComponentPluginManager::$defaults😊 That makes it more explicit, less magical.Comment #17
longwave#14 is not doable, we need a translatable string but you can't call
t()ornew TranslatableMarkupwhen initialising a class property.Fixed PHPStan, the baseline addition will be removed in #3352916: Fix PHPStan L1 errors "Call to method getDefinitions()/getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait."
Comment #18
wim leersAh, good point, @longwave! This is the most pragmatic approach, then :)
Comment #19
larowlanOne question on the MR about the phpstan baseline changes - if someone can confirm they're needed.
Fine to self RTBC afterwards
Comment #20
longwaveSee #17, the problem is in the trait, PHPStan doesn't catch it if you run it on the file alone - not sure why.
Alternatively if we land #3352916: Fix PHPStan L1 errors "Call to method getDefinitions()/getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait." first then the baseline changes can be removed.
Comment #22
larowlanCredits
Rerolled after #3352916: Fix PHPStan L1 errors "Call to method getDefinitions()/getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait.", only removed the baseline changes, if it comes back green will commit
Comment #23
larowlanCommitted to 11.x - thanks!