You are here

function drush_rules_export in Rules 8.3

Same name and namespace in other branches
  1. 7.2 rules.drush.inc \drush_rules_export()

Exports a single rule.

File

./rules.drush.inc, line 291
Rules module integration with Drush 8 and earlier.

Code

function drush_rules_export($rule) {

  // The $rule argument could refer to a Reaction Rule or a Rules Component.
  $config = \Drupal::service('config.storage')
    ->read('rules.reaction.' . $rule);
  if (empty($config)) {
    $config = \Drupal::service('config.storage')
      ->read('rules.component.' . $rule);
    if (empty($config)) {
      return drush_set_error('', dt('Could not find a Reaction Rule or a Rules Component named "@name".', [
        '@name' => $rule,
      ]));
    }
  }
  drush_print(Yaml::encode($config), 0, NULL, FALSE);
  drush_log(dt('The rule "@name" has been exported.', [
    '@name' => $rule,
  ]), 'success');
}