Skip to content

Instantly share code, notes, and snippets.

@fago
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

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

Select an option

Save fago/b1caea6731f147556955 to your computer and use it in GitHub Desktop.
Rules static helpers
<?php
$rule = \Drupal\rules\Rules::expressionManager()
->createRule([
'context_definitions' => [
'user' => [
'type' => 'entity:user',
'label' => 'User',
'description' => 'The user whose mail address to print.',
],
],
]);
$rule->addAction('rules_system_message', \Drupal\rules\Context\ContextConfig::create()
->map('message', 'user:mail:value'));
$config_entity = \Drupal\rules\Entity\RulesComponent::create([
'id' => 'rules_test_default_component'
])->setExpression($rule);
$config_entity->save();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment