Plugin factories needlessly restrict configuration to arrays

Created on 29 September 2013, over 11 years ago
Updated 1 May 2025, 11 days ago

Problem/Motivation

Right now, the way the plugin FactoryInterface is defined bounds $configuration to be an array. This sucks when you actually want to use a non-array as plugin configuration as you are bound to a method signature that does not make sense to you. As there is no way this method gets invoked in a generic manner anyway, I do think this is needlessly restrictive - so let's loosen the interface and base class to allow for non arrays also.

A concrete need for non-array based $configuration came up in #2047229: Make use of classes for entity field and data definitions β†’ , for which we'd need to convert the typed data manager createInstance() to receive a class as second parameter, which right now is an array. I'd much prefer to be able to actually fix that to a sane method signature there.

$configuration is forced to be a primitive array while many system will want to use classed objects as configuration to have dedicated methods and well defined configuration elements. Avoiding D7 array of doom syndrome.

Proposed resolution

Remove the array type hint for $configuration from all plugin (and manager) interfaces and implementations.

Remaining tasks

Patch review.

User interface changes

None.

API changes

All implementers and extenders of the plugin system will have to remove the array type hint from their function signatures. This will affect many modules but the change is VERY easy to make.

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

plugin system

Created by

πŸ‡¦πŸ‡ΉAustria fago Vienna

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024