Problem/Motivation
Feeds plugins can make use of annotation for injecting dependencies. See for example the feeds target "file":
/**
* Defines a file field mapper.
*
* @FeedsTarget(
* id = "file",
* field_types = {"file"},
* arguments = {
* "@entity_type.manager",
* "@entity.query",
* "@http_client",
* "@token",
* "@entity_field.manager",
* "@entity.repository",
* }
* )
*/
This is problematic because any plugins extending an existing Feeds plugin are required to declare the same dependencies. This can be seen for example on the "image" target:
/**
* Defines a file field mapper.
*
* @FeedsTarget(
* id = "image",
* field_types = {"image"},
* arguments = {
* "@entity_type.manager",
* "@entity.query",
* "@http_client",
* "@token",
* "@entity_field.manager",
* "@entity.repository",
* }
* )
*/
Now if a Feeds plugin needs to change their dependencies, then any plugin that extends it gets immediately broken, even if it didn't override the constructor method.
This resulted into a problem for stop using the deprecated "entity.query" service, used in several Feeds plugins. See #3001376: entity.query deprecated warnings.
In other words, Feeds can't be made compatible with Drupal 9 without introducing non-backwards compatible changes.
Proposed resolution
Deprecate FeedsAnnotationFactory and let plugins implement ContainerFactoryPluginInterface instead for dependency injection. The latter has also become a sort of standard for plugin dependencies. This reduces the amount of backwards compatibility breaks in the future: plugins extending an existing Feeds plugin and don't override the constructor, won't break so easily.
Remaining tasks
- Deprecate FeedsAnnotationFactory.
- Convert all Feeds plugins that are using annotation for dependency injection to use ContainerFactoryPluginInterface instead.
User interface changes
None.
API changes
- \Drupal\feeds\Plugin\Type\FeedsAnnotationFactory gets deprecated.
- Plugins extending existing Feeds plugins that now use annotation for dependency injection, will need to be updated.
Data model changes
None.
Release notes snippet
Declaring dependencies in the annotation for Feeds plugins got deprecated. Implement \Drupal\Core\Plugin\ContainerFactoryPluginInterface instead for injecting your dependencies.
Comments
Comment #2
megachrizThis first patch deprecates \Drupal\feeds\Plugin\Type\FeedsAnnotationFactory and changes the dependency injection for the Feeds target plugins "entity_reference", "file" and "image".
Let's see if something breaks.
Comment #3
megachrizComment #4
megachrizChanged dependency injection for all other plugins that used FeedsAnnotationFactory.
Comment #5
megachrizComment #6
megachrizReroll.
Comment #8
megachrizCommitted #6.