function VariableTranslation::values

Same name in this branch
  1. 11.x core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation::values()
Same name in other branches
  1. 9 core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation::values()
  2. 9 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\VariableTranslation::values()
  3. 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation::values()
  4. 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\VariableTranslation::values()
  5. 10 core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation::values()
  6. 10 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\VariableTranslation::values()

Return the values of the variables specified in the plugin configuration.

Return value

array An associative array where the keys are the variables specified in the plugin configuration and the values are the values found in the source. A key/value pair is added for the language code. Only those values are returned that are actually in the database.

1 call to VariableTranslation::values()
VariableTranslation::initializeIterator in core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php

File

core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php, line 70

Class

VariableTranslation
Drupal 7 variable_store source from database.

Namespace

Drupal\migrate_drupal\Plugin\migrate\source\d7

Code

protected function values() {
    $values = [];
    $result = $this->prepareQuery()
        ->execute()
        ->FetchAllAssoc('realm_key');
    foreach ($result as $variable_store) {
        $values[]['language'] = $variable_store['realm_key'];
    }
    $result = $this->prepareQuery()
        ->execute()
        ->FetchAll();
    foreach ($result as $variable_store) {
        foreach ($values as $key => $value) {
            if ($values[$key]['language'] === $variable_store['realm_key']) {
                if ($variable_store['serialized']) {
                    $values[$key][$variable_store['name']] = unserialize($variable_store['value']);
                    break;
                }
                else {
                    $values[$key][$variable_store['name']] = $variable_store['value'];
                    break;
                }
            }
        }
    }
    return $values;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.