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

  1. Deprecate FeedsAnnotationFactory.
  2. 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

MegaChriz created an issue. See original summary.

megachriz’s picture

Status: Active » Needs work
StatusFileSize
new5.39 KB

This 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.

megachriz’s picture

Changed dependency injection for all other plugins that used FeedsAnnotationFactory.

megachriz’s picture

Status: Needs work » Needs review
megachriz’s picture

  • MegaChriz committed 0a20f83 on 8.x-3.x
    Issue #3062533 by MegaChriz: Deprecate FeedsAnnotationFactory and let...
megachriz’s picture

Status: Needs review » Fixed

Committed #6.

Status: Fixed » Closed (fixed)

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