Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ProfileFieldOptionTranslation.php

function ProfileFieldOptionTranslation::transform

Overrides ProcessPluginBase::transform

File

core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php, line 23

Class

ProfileFieldOptionTranslation
Determines the settings property and translation.

Namespace

Drupal\user\Plugin\migrate\process\d6

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    [
        $field_type,
        $translation,
    ] = $value;
    $new_value = NULL;
    if (isset($translation)) {
        $allowed_values = [];
        $list = explode("\n", $translation);
        $list = array_map('trim', $list);
        $list = FilterArray::removeEmptyStrings($list);
        if ($field_type === 'list_string') {
            foreach ($list as $value) {
                $allowed_values[] = [
                    'label' => $value,
                ];
            }
        }
        $new_value = [
            'settings.allowed_values',
            $allowed_values,
        ];
    }
    return $new_value;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal