Condition plugin configuration forms depend on their parent forms

Created on 9 January 2016, over 8 years ago
Updated 28 February 2023, over 1 year ago

Problem/Motivation

ConditionPluginBase::buildConfiguration() depends on a form state item set by the parent form. This makes the form less portable, and although it may not be a violation of PluginFormInterface, it means that the plugins' forms are not as easy to embed as PluginFormInterface suggests.

Proposed resolution

Let ConditionPluginBase retrieve available contexts through the context.repository service itself if no contexts are stored in the form state. This also prevents problems when #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) β†’ is committed, because it would prevent plugin forms from accessing the global form state, and thus the globally set contexts.
The only current usage of this global form state key is in BlockForm::form(), and that is equivalent to the proposed solution.

Remaining tasks

Allow the context repository to be optionally injected to ConditionBase plugins through the constructor, and add a protected ::getContextRepository() method that uses service location in case the context repository is not injected. This causes a minor break of unit tests of code that calls ConditionPluginBase::buildConfiguration(), because the context repository is not mocked in those tests yet.

User interface changes

None.

API changes

None.

Data model changes

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
PluginΒ  β†’

Last updated about 15 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom Xano Southampton

Live updates comments and jobs are added and updated live.
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.

Production build 0.69.0 2024