I'm not fully satisfied with the current plugin system.
The main problem I see is that each plugin has is fixed name. That means it is impossible to have multiple plugins for the same behavior. A good example is a image resize plugin.
There could be multiple implementations:
Native ImageMagick plugin: Render images with the convert command natively. Only work on local filesystems.
Imagick plugin: Render images with the Imagick class in the memory. Works only if Imagick is available, but also works for non-local filesystems.
GD plugin: Render images with GD in memory. Works if GD is enabled and also works for non-local filesystems, but is more shoddy than Imagick.
Another feature could be native plugins. Plugins that are provided by the adapter to support adapter specific features. For a dropbox adapter this could be a build-in dropbox plugin.
So I wan't to do the following changes:
Add Adapter::getPlugins($name) return a list of native plugin objects.
Remove PluginInterface::getName()
Change PluginManager::registerPlugin(PluginInterface $plugin) to PluginManager::registerPlugin($name, PluginInterface $plugin, $priority = 0)
I'm not fully satisfied with the current plugin system.
The main problem I see is that each plugin has is fixed name. That means it is impossible to have multiple plugins for the same behavior. A good example is a image resize plugin.
There could be multiple implementations:
convert
command natively. Only work on local filesystems.Imagick
class in the memory. Works only ifImagick
is available, but also works for non-local filesystems.Another feature could be native plugins. Plugins that are provided by the adapter to support adapter specific features. For a dropbox adapter this could be a build-in dropbox plugin.
So I wan't to do the following changes:
Adapter::getPlugins($name)
return a list of native plugin objects.PluginInterface::getName()
PluginManager::registerPlugin(PluginInterface $plugin)
toPluginManager::registerPlugin($name, PluginInterface $plugin, $priority = 0)
PluginInterface::supportsAdapter(AdapterInterface $adapter)
PluginInterface::supportsFile(File $file)
PluginManager::getPlugin($name)
toPluginManager::getPlugin($name, Adapter $adapter, File $file = null)
Instead of returning exactly one plugin object, it could be possible to pass a magic plugin, that ask each plugin in the list.
I'm also not happy with the Filesystem Adapter and File Adapter alienation. I'm not sure if this is really necessary.
@discordier any hints?