function rules_upgrade_convert_rule_set
Converts a single rule set, including all of its rules.
1 call to rules_upgrade_convert_rule_set()
- rules_upgrade_form_submit in includes/
rules.upgrade.inc - Submit handler for the form.
File
-
includes/
rules.upgrade.inc, line 192
Code
function rules_upgrade_convert_rule_set($name, $cfg_old) {
$config = rules_plugin_factory('rule set');
$config->name = $name;
foreach (array(
'label',
'weight',
) as $key) {
if (isset($cfg_old[$key])) {
$config->{$key} = $cfg_old[$key];
}
}
if (isset($cfg_old['arguments'])) {
$vars =& $config->componentVariables();
foreach ($cfg_old['arguments'] as $var_name => $info) {
// Map data types as required.
if ($info['type'] == 'string') {
$info['type'] = 'text';
}
$vars[$var_name] = $info;
}
}
// Add in all rules of the set.
foreach (_rules_upgrade_fetch_all_rules() as $rule_name => $rule) {
if ($rule['#set'] == $name) {
drupal_set_message(' >> ' . t('Converting %plugin %name...', array(
'%plugin' => t('rule'),
'%name' => $rule_name . ': ' . $rule['#label'],
)));
$new_rule = rules_upgrade_plugin_factory($rule);
rules_upgrade_convert_element($rule, $new_rule);
$new_rule->setParent($config);
}
}
return $config;
}