Right now, conditions like the following cannot be completed as we miss the API for contextual plugins to fetch metadata of configured context:
#2281079: Port "Data comparison (data_is)" condition to 8.x
#2281083: Port "List contains item (list_contains)" condition to 8.x

Comments

fago created an issue. See original summary.

fago’s picture

fago’s picture

I think we could do this best by passing the array of mapped context definitions to refineContextDefinitions(). That way we keep the contextual plugins free of a dependency on the [metadata] execution state.

fago’s picture

Implemented #2677034: Context is not refined when checking integrity - so we see where refineContextDefinitions() is called. Prepared \Drupal\rules\Context\ContextHandlerTrait::getMappedDefinition() so this should be straight-forward now.

fago’s picture

Status: Active » Needs review

ok, I implemented this and add test-coverage for it. I used the Data comparison condition as example, thus included the fix for here.

For being able to solve that cleanly I had to separate prepareContextWithMetadata() from pepareContext(). It's partly duplication the run-time logic now, but the duplicating part is very small. We could make both methods re-use more codes by making even more re-used small helper methods but I do not think that helps a lot, given the many small differences. Moreover, this is probably a quite performance critical path so not having that many useless function calls in there cannot harm.

PR: https://github.com/fago/rules/pull/424 - building upon #2677034: Context is not refined when checking integrity.

  • fago committed 7f0d1a7 on 8.x-3.x
    Issue #2676996 by fago: Add test coverage for checking integrity based...
  • fago committed acf0fc6 on 8.x-3.x
    Issue #2676996 by fago: Allow contextual plugins to fetch metadata of...
fago’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

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