public function ScheduleEmailWebformHandler::getSummary in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php \Drupal\webform_scheduled_email\Plugin\WebformHandler\ScheduleEmailWebformHandler::getSummary()
Returns a render array summarizing the configuration of the webform handler.
Return value
array A render array.
Overrides EmailWebformHandler::getSummary
File
- modules/
webform_scheduled_email/ src/ Plugin/ WebformHandler/ ScheduleEmailWebformHandler.php, line 71
Class
- ScheduleEmailWebformHandler
- Schedules a webform submission's email.
Namespace
Drupal\webform_scheduled_email\Plugin\WebformHandlerCode
public function getSummary() {
$status_messages = [
WebformScheduledEmailManagerInterface::SUBMISSION_WAITING => [
'message' => $this
->t('waiting to be scheduled.'),
'type' => 'warning',
],
WebformScheduledEmailManagerInterface::SUBMISSION_QUEUED => [
'message' => $this
->t('queued to be sent.'),
'type' => 'status',
],
WebformScheduledEmailManagerInterface::SUBMISSION_READY => [
'message' => $this
->t('ready to be sent.'),
'type' => 'warning',
],
];
$cron_link = FALSE;
$build = [];
$stats = $this->scheduledEmailManager
->stats($this->webform, $this
->getHandlerId());
foreach ($stats as $type => $total) {
if (empty($total) || !isset($status_messages[$type])) {
continue;
}
$build[$type] = [
'#type' => 'webform_message',
'#message_message' => $this
->formatPlural($total, '@count email @message', '@count emails @message', [
'@message' => $status_messages[$type]['message'],
]),
'#message_type' => $status_messages[$type]['type'],
];
if ($status_messages[$type]['type'] === 'warning') {
$cron_link = TRUE;
}
}
// Display execute cron link.
if ($cron_link) {
$build['link'] = [
'#type' => 'link',
'#title' => $this
->t('Run cron task'),
'#url' => Url::fromRoute('entity.webform.scheduled_email.cron', [
'webform' => $this
->getWebform()
->id(),
'handler_id' => $this
->getHandlerId(),
]),
'#attributes' => [
'class' => [
'button',
'button--small',
],
],
'#prefix' => '<p>',
'#suffix' => '</p>',
];
}
$summary = parent::getSummary();
if ($build) {
$summary['#status'] = [
'#type' => 'details',
'#title' => $this
->t('Scheduled email status (@total)', [
'@total' => $stats['total'],
]),
'#help' => FALSE,
'#description' => $build,
];
}
return $summary;
}