LanguageTypes.php

Same filename in other branches
  1. 9 core/modules/language/src/Plugin/migrate/process/LanguageTypes.php
  2. 8.9.x core/modules/language/src/Plugin/migrate/process/LanguageTypes.php
  3. 11.x core/modules/language/src/Plugin/migrate/process/LanguageTypes.php

Namespace

Drupal\language\Plugin\migrate\process

File

core/modules/language/src/Plugin/migrate/process/LanguageTypes.php

View source
<?php

namespace Drupal\language\Plugin\migrate\process;

use Drupal\migrate\Attribute\MigrateProcess;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Processes the array for the language types.
 */
class LanguageTypes extends ProcessPluginBase {
    
    /**
     * {@inheritdoc}
     */
    public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
        if (!is_array($value)) {
            throw new MigrateException('The input should be an array');
        }
        if (array_key_exists('language', $value)) {
            $value['language_interface'] = $value['language'];
            unset($value['language']);
        }
        if (!empty($this->configuration['filter_configurable'])) {
            $value = array_filter($value);
        }
        return array_keys($value);
    }

}

Classes

Title Deprecated Summary
LanguageTypes Processes the array for the language types.

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