Problem/Motivation
In a 3rd-party I want to swap the SDC plugin class, which currently is src/Plugin/Component
- As we use to do that in Drupal, I first looked for something like `hook_SOMETHING_info_alter()`. But the SDC plugin manager says:
// Note that we are intentionally skipping $this->alterInfo('sdc_info'); // We want to ensure that everything related to a component is in the // single directory. If the alteration of a component is necessary, // component replacement is the preferred tool for that.
and doesn't provide such a hook
- No problem, I said. I will swap the plugin manager class, using a *ServiceProvider magic class, and I will add my own class in `DefaultPluginManager::$defaults`.
- No way, the `ComponentPluginManager` plugin manager class is final.
- Then I went with decorating. I've intercepted the definition in MyPluginManagerClass::processDefinition() and changed the class. It works.
- But now it crashes in `\Drupal\sdc\Twig\TwigComponentLoader::__construct()` because the plugin manager, passed as 1st argument, is strict-typed to `\Drupal\sdc\ComponentPluginManager`, so I can't pass the custom class that swapped SDC plugin manager.
Trying to extend SDC in any direction seems quite impossible, not only when to comes to my scope. The whole module seems so hermetic.
Steps to reproduce
See "Problem/Motivation"
Proposed resolution
- Allow to alter plugin definitions, as we allow in any Drupal plugin type.
- Remove "final" from plugin & plugin manager classes.
- Revisit strict-typing of parameters and and sure they're using the interface, not specific class