You are here

public function MigrationStorage::getVariantIds in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/MigrationStorage.php \Drupal\migrate\MigrationStorage::getVariantIds()

Splices variant IDs into a list of migration IDs.

IDs which match the template_id:* pattern are shorthand for every variant of template_id. This method queries for those variant IDs and splices them into the original list.

Parameters

string[] $ids: A set of migration IDs.

Return value

string[] The expanded list of IDs.

2 calls to MigrationStorage::getVariantIds()
MigrationStorage::loadMultiple in core/modules/migrate/src/MigrationStorage.php
Loads one or more entities.
TestMigrationStorage::getVariantIds in core/modules/migrate/tests/src/Unit/MigrationStorageTest.php
Splices variant IDs into a list of migration IDs.
1 method overrides MigrationStorage::getVariantIds()
TestMigrationStorage::getVariantIds in core/modules/migrate/tests/src/Unit/MigrationStorageTest.php
Splices variant IDs into a list of migration IDs.

File

core/modules/migrate/src/MigrationStorage.php, line 95
Contains \Drupal\migrate\MigrationStorage.

Class

MigrationStorage
Storage for migration entities.

Namespace

Drupal\migrate

Code

public function getVariantIds(array $ids) {

  // Re-index the array numerically, since we need to limit the loop by size.
  $ids = array_values($ids);
  $index = 0;
  while ($index < count($ids)) {
    if (substr($ids[$index], -2) == ':*') {
      $template_id = substr($ids[$index], 0, -2);
      $variants = $this->queryFactory
        ->get($this->entityType, 'OR')
        ->condition('id', $template_id)
        ->condition('template', $template_id)
        ->execute();
      array_splice($ids, $index, 1, $variants);
      $index += count($variants);
    }
    else {
      $index++;
    }
  }
  return $ids;
}