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

Breadcrumb

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

function FieldBundle::transform

Overrides ProcessPluginBase::transform

File

core/modules/field/src/Plugin/migrate/process/d7/FieldBundle.php, line 97

Class

FieldBundle
Determines the bundle for a field.

Namespace

Drupal\field\Plugin\migrate\process\d7

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    [
        $entity_type,
        $bundle,
    ] = $value;
    $lookup_result = NULL;
    // For comment entity types get the destination bundle from the
    // d7_comment_type migration, if it exists.
    if ($entity_type === 'comment' && $bundle != 'comment_forum') {
        $lookup_result = $row->get('@_comment_type');
        // Legacy generated migrations will not have the destination property
        // '_comment_type'.
        if (!$row->hasDestinationProperty('_comment_type')) {
            $value = str_replace('comment_node_', '', $bundle);
            $migration = 'd7_comment_type';
            $lookup_result = $this->migrateLookup
                ->lookup($migration, [
                $value,
            ]);
            $lookup_result = empty($lookup_result) ? NULL : reset($lookup_result[0]);
        }
    }
    return $lookup_result ? $lookup_result : $bundle;
}

API Navigation

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