protected function D6Webform::buildEmailHandlers in Webform: Migrate 8
Same name and namespace in other branches
- 8.2 src/Plugin/migrate/source/d6/D6Webform.php \Drupal\webform_migrate\Plugin\migrate\source\d6\D6Webform::buildEmailHandlers()
Build email handlers from webform emails table.
1 call to D6Webform::buildEmailHandlers()
- D6Webform::prepareRow in src/
Plugin/ migrate/ source/ d6/ D6Webform.php - Adds additional data to the row.
File
- src/
Plugin/ migrate/ source/ d6/ D6Webform.php, line 462
Class
- D6Webform
- Drupal 6 webform source from database.
Namespace
Drupal\webform_migrate\Plugin\migrate\source\d6Code
protected function buildEmailHandlers($nid, $xref) {
$query = $this
->select('webform_emails', 'we');
$query
->fields('we', [
'nid',
'eid',
'email',
'subject',
'from_name',
'from_address',
'template',
'excluded_components',
'html',
'attachments',
]);
$emails = $query
->condition('nid', $nid)
->execute();
$handlers = [];
foreach ($emails as $email) {
$id = 'email_' . $email['eid'];
foreach ([
'email',
'subject',
'from_name',
'from_address',
] as $field) {
if (!empty($email[$field]) && is_numeric($email[$field]) && !empty($xref[$email[$field]])) {
$email[$field] = "[webform-submission:values:{$xref[$email[$field]]}:raw]";
}
}
$excluded = [];
if (!empty($email['excluded_components'])) {
$excludes = explode(',', $email['excluded_components']);
foreach ($excludes as $exclude) {
if (!empty($xref[$exclude])) {
$excluded[$xref[$exclude]] = $xref[$exclude];
}
}
}
$handlers[$id] = [
'id' => 'email',
'label' => 'Email ' . $email['eid'],
'handler_id' => $id,
'status' => 1,
'weight' => $email['eid'],
'settings' => [
'to_mail' => $email['email'],
'from_mail' => $email['from_address'],
'from_name' => $email['from_name'],
'subject' => $email['subject'],
'body' => $email['template'],
'html' => $email['html'],
'attachments' => $email['attachments'],
'excluded_elements' => $excluded,
],
];
}
return $handlers;
}