You are here

public function TimeZone::transform in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/src/Plugin/migrate/process/d6/TimeZone.php \Drupal\system\Plugin\migrate\process\d6\TimeZone::transform()
  2. 10 core/modules/system/src/Plugin/migrate/process/d6/TimeZone.php \Drupal\system\Plugin\migrate\process\d6\TimeZone::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

core/modules/system/src/Plugin/migrate/process/d6/TimeZone.php, line 21

Class

TimeZone
Process the D6 Timezone offset into a D8 compatible timezone name.

Namespace

Drupal\system\Plugin\migrate\process\d6

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $offset = $value;

  // Convert the integer value of the offset (which can be either
  // negative or positive) to a timezone name.
  // Note: Daylight saving time is not to be used.
  $timezone_name = timezone_name_from_abbr('', intval($offset), 0);
  if (!$timezone_name) {
    $timezone_name = 'UTC';
  }
  return $timezone_name;
}