Skip to content

Instantly share code, notes, and snippets.

@fago
Created February 8, 2015 14:01
Show Gist options
  • Select an option

  • Save fago/a971e9af8d34e8343874 to your computer and use it in GitHub Desktop.

Select an option

Save fago/a971e9af8d34e8343874 to your computer and use it in GitHub Desktop.
Mapping required and provided context
<?php
$rule = $this->expressionManager->createRule();
// The condition provides a "provided_text" variable.
$rule->addCondition('rules_test_provider');
// The action provides a "concatenated" variable.
$rule->addAction('rules_test_string', [
'context_mapping' => ['text:select' => 'provided_text'],
]);
// Add the same action again which will provide a "concatenated2" variable
// now.
$rule->addAction('rules_test_string', [
'context_mapping' => ['text:select' => 'concatenated'],
'provides_mapping' => ['concatenated' => 'concatenated2'],
]);
$rule->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment