function rules_i18n_rules_config_update

Implements hook_rules_config_update().

2 calls to rules_i18n_rules_config_update()
hook_rules_config_defaults_rebuild in ./rules.api.php
Act after rebuilding default configurations.
rules_i18n_rules_config_defaults_rebuild in rules_i18n/rules_i18n.module
Implements hook_rules_config_defaults_rebuild().

File

rules_i18n/rules_i18n.module, line 73

Code

function rules_i18n_rules_config_update($rules_config, $original = NULL) {
    // Do nothing when rebuilding defaults to avoid multiple cache rebuilds.
    // @see rules_i18n_rules_config_defaults_rebuild()
    if (!empty($rules_config->is_rebuild)) {
        return;
    }
    $original = $original ? $original : $rules_config->original;
    // Account for name changes.
    if ($original->name != $rules_config->name) {
        i18n_string_update_context("rules:rules_config:{$original->name}:*", "rules:rules_config:{$rules_config->name}:*");
    }
    // We need to remove the strings of any disappeared properties, i.e. strings
    // from translatable parameters of deleted actions.
    // i18n_object() uses a static cache per config, so bypass it to wrap the
    // original entity.
    $object_key = i18n_object_key('rules_config', $original);
    $old_i18n_object = new RulesI18nStringObjectWrapper('rules_config', $object_key, $original);
    $old_strings = $old_i18n_object->get_strings(array(
        'empty' => TRUE,
    ));
    // Note: For the strings to have updated values, the updated entity needs to
    // be handled last due to i18n's cache.
    $strings = i18n_object('rules_config', $rules_config)->get_strings(array(
        'empty' => TRUE,
    ));
    foreach (array_diff_key($old_strings, $strings) as $name => $string) {
        $string->remove(array(
            'empty' => TRUE,
        ));
    }
    // Now update the remaining strings.
    foreach ($strings as $string) {
        $string->update(array(
            'empty' => TRUE,
            'update' => TRUE,
        ));
    }
}