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.

Files: 
CommentFileSizeAuthor
#10 d8_documentation.patch2.52 KBfago
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,769 pass(es). View
#2 d8_changes.patch3.18 KBfago
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,633 pass(es). View
#2 d8_document.interdiff.txt2.52 KBfago
#1 d8_changes.patch3.18 KBfago
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 77,732 pass(es). View

Comments

fago’s picture

Title: Document forseeable changes to conditions and action APIs » Document foreseeable changes to conditions and action APIs
Status: Active » Needs review
FileSize
3.18 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 77,732 pass(es). View

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

fago’s picture

FileSize
2.52 KB
3.18 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,633 pass(es). View

Fixed the WARNING format to be in-line with the one used hook_entity_bundle_field_info_alter().

fago’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes
klausi’s picture

Status: Needs review » Reviewed & tested by the community

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

tim.plunkett’s picture

+1

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed d805ed7 and pushed to 8.0.x. Thanks!

  • alexpott committed d805ed7 on 8.0.x
    Issue #2268467 by fago: Document foreseeable changes to conditions and...
klausi’s picture

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

fago’s picture

Status: Fixed » Needs review
FileSize
2.52 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 78,769 pass(es). View

oh, 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 --

klausi’s picture

Priority: Major » Minor
Status: Needs review » Reviewed & tested by the community

Cool. Let's see if setting an issue to RTBC + minor works to get this committed faster :-)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e114ff9 and pushed to 8.0.x. Thanks!

  • alexpott committed e114ff9 on 8.0.x
    Issue #2268467 followup by fago: Document foreseeable changes to...

Status: Fixed » Closed (fixed)

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