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

Breadcrumb

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

function ComponentEntityDisplayBase::import

Overrides MigrateDestinationInterface::import

File

core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php, line 67

Class

ComponentEntityDisplayBase
Provides a destination plugin for migrating entity display components.

Namespace

Drupal\migrate\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
    $values = [];
    // array_intersect_key() won't work because the order is important because
    // this is also the return value.
    foreach (array_keys($this->getIds()) as $id) {
        $values[$id] = $row->getDestinationProperty($id);
    }
    $entity = $this->getEntity($values['entity_type'], $values['bundle'], $values[static::MODE_NAME]);
    if (!$row->getDestinationProperty('hidden')) {
        $entity->setComponent($values['field_name'], $row->getDestinationProperty('options') ?: []);
    }
    else {
        $entity->removeComponent($values['field_name']);
    }
    $entity->save();
    return array_values($values);
}

API Navigation

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