You are here

protected function MigrateRecipe61Test::addUnitKeys in Recipe 8.2

Translates D6 unit names to D7 unit_keys.

Parameters

array $ingredients: A array of ingredient metadata from the D6 database.

Return value

array The results array with a unit_key item to each ingredient.

1 call to MigrateRecipe61Test::addUnitKeys()
MigrateRecipe61Test::testRecipeFields in tests/src/Kernel/Migrate/recipe61/MigrateRecipe61Test.php
Tests the Drupal 6 recipe to Drupal 8 migration.

File

tests/src/Kernel/Migrate/recipe61/MigrateRecipe61Test.php, line 133

Class

MigrateRecipe61Test
@covers \Drupal\recipe\Plugin\migrate\source\recipe61\Recipe61 @group recipe

Namespace

Drupal\Tests\recipe\Kernel\Migrate\recipe61

Code

protected function addUnitKeys(array $ingredients) {
  foreach ($ingredients as $key => $ingredient) {
    $ingredient->name = strtolower($ingredient->name);
    $ingredients[$key]->unit_key = isset(Recipe61::CHANGED_UNITS[$ingredient->name]) ? Recipe61::CHANGED_UNITS[$ingredient->name] : $ingredient->name;
  }
  return $ingredients;
}