You are here

public function CommerceRefreshMode::transform in Commerce Migrate 8.2

Same name and namespace in other branches
  1. 3.1.x modules/commerce/src/Plugin/migrate/process/commerce1/CommerceRefreshMode.php \Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1\CommerceRefreshMode::transform()
  2. 3.0.x modules/commerce/src/Plugin/migrate/process/commerce1/CommerceRefreshMode.php \Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1\CommerceRefreshMode::transform()

Performs the associated process.

Parameters

mixed $value: The value to be transformed.

\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.

\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.

string $destination_property: The destination property currently worked on. This is only used together with the $row above.

Return value

string|array The newly transformed value.

Overrides ProcessPluginBase::transform

File

modules/commerce/src/Plugin/migrate/process/commerce1/CommerceRefreshMode.php, line 25

Class

CommerceRefreshMode
Transforms the force and refresh mode Commerce 1 values to refresh mode.

Namespace

Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $new_value = NULL;
  if (is_array($value) && !empty($value)) {
    list($force, $refresh_mode) = $value;

    // If force is true then use the default 'always'.
    if ($force) {
      $new_value = 'always';
    }
    else {

      // If the refresh mode is not always then it is the default 'customer'.
      if ($refresh_mode != 'always') {
        $new_value = 'customer';
      }
    }
  }
  return $new_value;
}