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

Breadcrumb

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

function ArrayBuild::transform

Overrides ProcessPluginBase::transform

2 calls to ArrayBuild::transform()
LanguageDomains::transform in core/modules/language/src/Plugin/migrate/process/LanguageDomains.php
Performs the associated process.
LanguageDomains::transform in core/modules/language/src/Plugin/migrate/process/LanguageDomains.php
Performs the associated process.
1 method overrides ArrayBuild::transform()
LanguageDomains::transform in core/modules/language/src/Plugin/migrate/process/LanguageDomains.php
Performs the associated process.

File

core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php, line 82

Class

ArrayBuild
Builds an array based on the key and value configuration.

Namespace

Drupal\migrate\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $new_value = [];
    foreach ((array) $value as $old_value) {
        // Checks that $old_value is an array.
        if (!is_array($old_value)) {
            throw new MigrateException("The input should be an array of arrays");
        }
        // Checks that the key exists.
        if (!array_key_exists($this->configuration['key'], $old_value)) {
            throw new MigrateException("The key '" . $this->configuration['key'] . "' does not exist");
        }
        // Checks that the value exists.
        if (!array_key_exists($this->configuration['value'], $old_value)) {
            throw new MigrateException("The key '" . $this->configuration['value'] . "' does not exist");
        }
        $new_value[$old_value[$this->configuration['key']]] = $old_value[$this->configuration['value']];
    }
    return $new_value;
}

API Navigation

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