In order to provide a stable API for alpha1, we need to remove ambiguity of some methods names, and rely on interfaces as much as possible.

After audit, it appears source plugins is the scope to focus on.

First step: Source plugins manager

The easy and "obvious" stuff.

  • Replace the uses of SourcePluginManager::getSourcePluginById() in Form Builder and Element Builder by a 2 steps processes (in the reverse order):
    • ContextAwarePluginManagerInterface::getDefinitionsForContexts($contexts) to get the definitions whose constraints are satisfied by a set of contexts
    • FactoryInterface::createInstance() , passing the configuration array with prop_id, prop_definition, prop_definition & form_value
  • Rename getSourcePlugins(), used by the Form Builder, by getPluginsByPropType(). And rename getSourceDefinitions() by getDefinitionsByPropTyped() and make it protected
  • Do we move getDefaultSourcePlugin() logic to PropTypeInterface::getDefaultSource() (which can replace PropTypeInterface::getDefaultSourceId() which is used nowhere else) ?

Second step: Source plugins

Current investigation. Let's talk about this.

  • Use PluginFormInterface::buildConfigurationForm() in source plugins instead of SourcePluginBase:buildSourceConfigurationForm(), moving the wrapping of SourcePluginBase::buildConfigurationForm() into the form builder. So, every expected methods in a plugin class belong to a defined interface
  • PluginFormInterface::validateConfigurationForm() is not used by the form builder. are we missing something?
  • ContextAwarePluginInterface methods are not used by the Form Builder, only internally by SourcePluginBase. is it normal ?
Command icon 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

pdureau created an issue. See original summary.

pdureau’s picture

Issue summary: View changes
pdureau’s picture

Assigned: Unassigned » pdureau
pdureau’s picture

Issue summary: View changes

pdureau’s picture

Status: Active » Needs work

The MR about Source plugin manager methods https://git.drupalcode.org/project/ui_patterns/-/merge_requests/52

With:

  • SourcePluginManager is now using ContextAwarePluginManagerInterface and has 4 public methods: getDefinitionsForPropType, getPropTypeDefault, createInstances, & isApplicable
  • ComponentElementBuilder is updated to use those new methods
  • A temporary OldSourceManagerTrait is added to not break the current ComponentFormBuilderTrait rewrite

  • pdureau committed 6f50e959 on 2.0.x
    Issue #3413703 by pdureau: Source plugins: methods naming and interfaces...
pdureau’s picture

Before doing the second step (about Source plugins), let's change the use of SourcePluginManager methods and remove OldSourceManagerTrait (

pdureau’s picture

Title: [2.0.0-alpha1] Source plugins: methods naming and interfaces use » [2.0.0-alpha1] Source plugin manager: methods naming and interfaces use

"Second step: Source plugins" was moved to its own issue: #3414291: [2.0.0-alpha1] Source plugins:methods naming and interfaces use

So, lets keep this issue only for source plugin manager methods.

  • pdureau committed 13e8af35 on 2.0.x
    Issue #3413703 by just_like_good_vibes: Fix typing in Source Plugin...
pdureau’s picture

Once OldSourceManagerTrait will be removed by #3395953: [2.0.0-alpha1] Add new Form Builder we will be able to close this issue

pdureau’s picture

Assigned: christian.wiedemann » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.