Problem/Motivation
Media source instances carry a getMetadata() method. As this is not pluginified, extending it requires us to decorate the class. (Remember: decorating is not swapping a subclass in, as that will break other decorators(todo: link issue)). As simpler solutions did not work out (todo: link to documentation), we first had to decorate the manager.
In the Media Imagick module i implemented that successfully (and in a reusable way), but get a WSOD as at least 1 place in core programs against the class and not an interface:
TypeError: Argument 1 passed to Drupal\media\MediaTypeForm::__construct() must be an instance of Drupal\media\MediaSourceManager, instance of Drupal\plugindecorator\PluginManagerDecorator
Proposed resolution
Create a DefaultPluginManagerInterface and use it.
Daring to target 8.6 and raise prio as this blocks a stable release of a contrib module and is important to the media system.
Remaining tasks
Code, test, commit.
User interface changes
None.
API changes
Interface added.
Data model changes
None.
Comments
Comment #2
geek-merlinComment #3
geek-merlinStraightforward patch flying in. Gonna test it now.
Comment #4
geek-merlinTested. This fixes the WS for me and makes the module work. Daring to RTBC to kindly ping captain picard.
Comment #5
alexpott@axel.rutz I'm pretty sure you know the community convention that you shouldn't rtbc your own work.
This is not needed. We should typehint against Drupal\Component\Plugin\PluginManagerInterface and be done. No need for the new Core/Plugin code. For prior art look at all the other plugin managers in core eg.
interface LocalTaskManagerInterface extends PluginManagerInterface
Comment #6
geek-merlinThanks @alexpott for the quick reply and guidance! ❤
> We should typehint against Drupal\Component\Plugin\PluginManagerInterface and be done.
All the better. Updated patch implements that.
Comment #7
phenaproximaMediaSourceManager does not implement any methods that don't already exist on PluginManagerInterface, so this change makes sense and does not break the API or have BC implications. If it will help contrib, let's go for it. RTBC once green on all backends.
Comment #8
phenaproximaTargeting 8.7.x with intent to (hopefully) backport.
Comment #9
phenaproximaRe-titling for clarity.
Comment #10
geek-merlin@phenaproxima:
Thanks a lot for the review! ❤
I can confirm that this makes media_imagick work.
Comment #11
alexpottCommitted and pushed d67d9f3248 to 8.7.x and 3ef46a6c24 to 8.6.x. Thanks!
Comment #14
tstoeckler