ProfileFieldOptionTranslation.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldOptionTranslation.php
- 9 core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
- 10 core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldOptionTranslation.php
- 10 core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
- 11.x core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldOptionTranslation.php
- 11.x core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
Namespace
Drupal\user\Plugin\migrate\process\d6File
-
core/
modules/ user/ src/ Plugin/ migrate/ process/ d6/ ProfileFieldOptionTranslation.php
View source
<?php
namespace Drupal\user\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Determines the settings property and translation.
*
* @MigrateProcessPlugin(
* id = "d6_profile_field_option_translation",
* handle_multiples = TRUE
* )
*/
class ProfileFieldOptionTranslation extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($field_type, $translation) = $value;
$new_value = NULL;
if (isset($translation)) {
$allowed_values = [];
$list = explode("\n", $translation);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
if ($field_type === 'list_string') {
foreach ($list as $key => $value) {
$allowed_values[] = [
'label' => $value,
];
}
}
$new_value = [
'settings.allowed_values',
$allowed_values,
];
}
return $new_value;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
ProfileFieldOptionTranslation | Determines the settings property and translation. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.