Motivation
Conditions and Actions APIs in core are not able to serve all pre-existing contrib use cases in their current state. Modules like Rules and Panels/CTools have some additional needs which the APIs do not satisfy yet. It's the goal to have a common actions and conditions API in drupal 8 in core, such that modules do not have to fork the APIs and developers can rely on a consistent API, while site-builders benefit from existing plugins to be better interoperable.
The impact of API additions/changes to actions and conditions in core is rather low as modules mostly implement them for CTools/Rules APIs use-cases anyway, which are still under development.
Proposed resolution
Document the known outstanding changes as todos in the code, so that the developers already implementing the APIs are aware of coming changes.
User interface changes
-
API changes
- (in referenced issues)
Original report by @fago
The conditions API does not meet the requirements for Rules yet, e.g. there is #1976758: Plugins miss metadata about configuration. Moreover, there there will be further missing features and or incompatibilities that the core API does not yet provide. The situation is similar for the action API, but a bit different as in contrast to the condition API the action API is already used.
Off the top of my head some missing features or incompatibilities are
- One problematic area is #1976758: Plugins miss metadata about configuration and how configuration forms are built, as Rules needs the possibility to override it by parameter/context
- Specifying options lists for a parameters
- Providing metadata assertions (should be doable as API addition)
- The definition of a context, i.e. the context class does not add any value compared to typed data definitions right now and is questionable whether its useful as it is.
- Handling of NULL values (allowed/disallowed) + a way to opt out
- Generation additional parameters/contexts depending on the values of others (should be doable as addition)
- The ability to process context values, mostly important for applying token replacements (important for actions, but applicable to conditions as well)
- Separating out entity saves from action implementations (applies to actions only)
The last two points apply to actions as well and are API changes to a lot of action implementations, so most problematic - not sure if changing them after beta is possible. The latter one would be hard to fix, but processing context values isn't that simple. If we cannot reach compatibility here it would mean that Rules would have to do its own actions API variant. But it would be great if we manage a common conditions API at least.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | d8_documentation.patch | 2.52 KB | fago |
| #2 | d8_changes.patch | 3.18 KB | fago |
| #2 | d8_document.interdiff.txt | 2.52 KB | fago |
| #1 | d8_changes.patch | 3.18 KB | fago |
Comments
Comment #1
fagoAs the beta is nearing, it would be great to get foreseeable changes documented. For that, I've gone through all of the points, created issues if necessary and added a warning with pointers to expected changes to interfaces.
Created/referenced issues are:
#2346999: Make ContextDefinitionInterface more expressible
#2011038: Use Context system for actions
#2347017: Allow actions to mark their required context for saving
#2347023: Move processing plugin context to data processors
#2172017: Bulk operations does not respect entity access
Patch attached.
Comment #2
fagoFixed the WARNING format to be in-line with the one used hook_entity_bundle_field_info_alter().
Comment #3
fagoComment #4
fagoComment #5
klausiReviewed this with fago at drupalcon, this looks like the most sensible way to move forward. The emphasis is that it only concerns a limited group of developers that are impacted by the outstanding action and condition API changes - and they are well aware that this will have to change in order to be useful.
Comment #6
tim.plunkett+1
Comment #7
alexpottCommitted d805ed7 and pushed to 8.0.x. Thanks!
Comment #9
klausiI think alexpott committed the wrong patch without the @todo change, but since it was just a minor improvement I guess we can leave this as is.
Comment #10
fagooh, that's my fault :-( I accidentally uploaded the old patch file with the new interdiff, so the changes of the interdiff are missing. Attached is a patch to re-add those changes: They add the missing @todos and a s/Condition/Conditions.
Patch-workflow --
Comment #11
klausiCool. Let's see if setting an issue to RTBC + minor works to get this committed faster :-)
Comment #12
alexpottCommitted e114ff9 and pushed to 8.0.x. Thanks!