You are here

protected function RulesPlugin::returnExport in Rules 7.2

Finalizes the configuration export.

Adds general attributes regarding the configuration and returns it in the right format for export.

Parameters

$export:

string $prefix: An optional prefix for each line.

bool $php: (optional) Set to TRUE to format the export using PHP arrays. By default JSON is used.

1 call to RulesPlugin::returnExport()
RulesPlugin::export in includes/rules.core.inc
Exports a rule configuration.

File

includes/rules.core.inc, line 1448
Rules base classes and interfaces needed for any rule evaluation.

Class

RulesPlugin
Base class for rules plugins.

Code

protected function returnExport($export, $prefix = '', $php = FALSE) {
  $this
    ->ensureNameExists();
  if (!empty($this->label) && $this->label != t('unlabeled')) {
    $export_cfg[$this->name]['LABEL'] = $this->label;
  }
  $export_cfg[$this->name]['PLUGIN'] = $this
    ->plugin();
  if (!empty($this->weight)) {
    $export_cfg[$this->name]['WEIGHT'] = $this->weight;
  }
  if (isset($this->active) && !$this->active) {
    $export_cfg[$this->name]['ACTIVE'] = FALSE;
  }
  if (!empty($this->owner)) {
    $export_cfg[$this->name]['OWNER'] = $this->owner;
  }
  if (!empty($this->tags)) {
    $export_cfg[$this->name]['TAGS'] = $this->tags;
  }
  if ($modules = $this
    ->dependencies()) {
    $export_cfg[$this->name]['REQUIRES'] = $modules;
  }
  if (!empty($this->access_exposed)) {
    $export_cfg[$this->name]['ACCESS_EXPOSED'] = $this->access_exposed;
  }
  $export_cfg[$this->name] += $export;
  return $php ? entity_var_export($export_cfg, $prefix) : entity_var_json_export($export_cfg, $prefix);
}