You are here

protected function FarmLog::prepareQuantity in farmOS 2.x

Prepare a log's quantity information.

Parameters

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

1 call to FarmLog::prepareQuantity()
FarmLog::prepareRow in modules/core/migrate/src/Plugin/migrate/source/d7/FarmLog.php
Adds additional data to the row.

File

modules/core/migrate/src/Plugin/migrate/source/d7/FarmLog.php, line 245

Class

FarmLog
Log source from database.

Namespace

Drupal\farm_migrate\Plugin\migrate\source\d7

Code

protected function prepareQuantity(Row $row) {
  $id = $row
    ->getSourceProperty('id');

  // Get field collections to migrate to log quantities.
  $log_quantities = $this
    ->getFieldvalues('log', 'field_farm_quantity', $id);
  $log_inventories = $this
    ->getFieldvalues('log', 'field_farm_inventory', $id);

  // Iterate through field collection values to collect field collection IDs.
  $quantity_ids = [];
  foreach (array_merge($log_quantities, $log_inventories) as $field_collection) {
    if (!empty($field_collection['value'])) {
      $quantity_ids[] = $field_collection['value'];
    }
  }

  // Add the quantity IDs to the row for future processing.
  $row
    ->setSourceProperty('log_quantities', $quantity_ids);
}