You are here

public function AclTable::import in ACL 8

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

\Drupal\migrate\Row $row: The row object.

array $old_destination_id_values: (optional) The old destination IDs. Defaults to an empty array.

Return value

array|bool An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

Overrides MigrateDestinationInterface::import

File

src/Plugin/migrate/destination/AclTable.php, line 61

Class

AclTable
Drupal 8 ACL Table destination.

Namespace

Drupal\acl\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = array()) {
  $destination = $row
    ->getDestination();
  $keys = array();
  foreach (array_keys($this->ids) as $id) {
    $keys[$id] = $destination[$id];
    unset($destination[$id]);
  }
  \Drupal::database()
    ->merge($this->table_name)
    ->keys($keys)
    ->fields($destination)
    ->execute();
  $return = array_map(function ($key) use ($row) {
    return $row
      ->getDestinationProperty($key);
  }, $keys);
  return $return;
}