X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate_drupal%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd6%2Fi18nVariable.php;h=f1c338a3274ad0e4d6995915fb2d70e40aad8e0d;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=93832aa75b27051b825a9e74c33019cbd881318b;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php b/web/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php index 93832aa75..f1c338a32 100644 --- a/web/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php +++ b/web/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php @@ -2,99 +2,19 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source\d6; -use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\State\StateInterface; -use Drupal\migrate\Plugin\MigrationInterface; -use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; +@trigger_error('The ' . __NAMESPACE__ . '\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\VariableTranslation', E_USER_DEPRECATED); /** * Drupal i18n_variable source from database. * * @MigrateSource( - * id = "i18n_variable" + * id = "i18n_variable", + * source_module = "system", * ) + * + * @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use + * \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation instead. + * + * @see https://www.drupal.org/node/2898649 */ -class i18nVariable extends DrupalSqlBase { - - /** - * The variable names to fetch. - * - * @var array - */ - protected $variables; - - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); - $this->variables = $this->configuration['variables']; - } - - /** - * {@inheritdoc} - */ - protected function initializeIterator() { - return new \ArrayIterator($this->values()); - } - - /** - * Return the values of the variables specified in the plugin configuration. - * - * @return 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. - */ - protected function values() { - $values = []; - $result = $this->prepareQuery()->execute()->FetchAllAssoc('language'); - foreach ($result as $i18n_variable) { - $values[]['language'] = $i18n_variable->language; - } - $result = $this->prepareQuery()->execute()->FetchAll(); - foreach ($result as $i18n_variable) { - foreach ($values as $key => $value) { - if ($values[$key]['language'] === $i18n_variable->language) { - $values[$key][$i18n_variable->name] = unserialize($i18n_variable->value); - break; - } - } - } - return $values; - } - - /** - * {@inheritdoc} - */ - public function count() { - return $this->initializeIterator()->count(); - } - - /** - * {@inheritdoc} - */ - public function fields() { - return array_combine($this->variables, $this->variables); - } - - /** - * {@inheritdoc} - */ - public function query() { - return $this->getDatabase() - ->select('i18n_variable', 'v') - ->fields('v') - ->condition('name', (array) $this->configuration['variables'], 'IN'); - } - - /** - * {@inheritdoc} - */ - public function getIds() { - $ids['language']['type'] = 'string'; - return $ids; - } - -} +class i18nVariable extends VariableTranslation {}