You are here

public function MessageTemplateProcessText::transform in Message 8

Transform the message template texts.

Overrides ProcessPluginBase::transform

File

src/Plugin/migrate/process/MessageTemplateProcessText.php, line 21

Class

MessageTemplateProcessText
Plugin annotation @MigrateProcessPlugin( id = "d7_message_template_text" )

Namespace

Drupal\message\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $source = $row
    ->getSource();
  $message_tpl = \Drupal::entityTypeManager()
    ->getStorage('message_template')
    ->load($row
    ->getSource()['name']);
  $texts = [];
  if (!empty($message_tpl)) {
    $texts = $message_tpl
      ->getRawText();
  }
  $texts[] = [
    'value' => $source['message_text_value'],
    'format' => $source['message_text_format'],
  ];
  return $texts;
}