public function PhoneNumberSettings::transform in SMS Framework 8
Same name and namespace in other branches
- 2.x src/Plugin/migrate/process/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\process\PhoneNumberSettings::transform()
- 2.1.x src/Plugin/migrate/process/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\process\PhoneNumberSettings::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
- src/
Plugin/ migrate/ process/ PhoneNumberSettings.php, line 25
Class
- PhoneNumberSettings
- Creates phone number settings for new D8 site based on D6/D7 settings.
Namespace
Drupal\sms\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if ($row
->getSourceProperty('id') === 'sms_user_confirmation_message') {
// If still using the D6/D7 default message, swap for the new D8 default.
if (empty($value) || $value == static::DEFAULT_D6_VERIFICATION_MESSAGE || $value == static::DEFAULT_D7_VERIFICATION_MESSAGE) {
$value = static::DEFAULT_VERIFICATION_MESSAGE;
}
else {
// Replace both D6 and D7 message token formats.
$value = str_replace('[site-name]', '[site:name]', $value);
$value = str_replace('[confirm-code]', '[sms-message:verification-code]', $value);
$value = str_replace('[confirm:code]', '[sms-message:verification-code]', $value);
}
}
return $value;
}