public function DevelopmentEnvironmentController::logListPage in Development Environment 8
Creates the log page listing all email logs.
Return value
array A render array representing the email log listing page.
Overrides DevelopmentEnvironmentControllerInterface::logListPage
1 string reference to 'DevelopmentEnvironmentController::logListPage'
File
- src/
Controller/ DevelopmentEnvironmentController.php, line 100
Class
- DevelopmentEnvironmentController
- The DevelopmentEnvironmentController class.
Namespace
Drupal\development_environment\ControllerCode
public function logListPage() {
$query = $this->database
->select('development_environment_log', 'log_data')
->extend('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender');
$query
->fields('log_data', [
'lid',
'email_data',
'timestamp',
'recipient_email',
'subject',
]);
$log_items = $query
->limit(20)
->orderBy('lid', 'DESC')
->execute();
$page = [
'form' => $this->formBuilder
->getForm('\\Drupal\\development_environment\\Form\\DevelopmentEnvironmentClearLogForm'),
'items' => [
'#theme' => 'table',
'#header' => [
'',
$this
->t('Time'),
$this
->t('Recipient'),
$this
->t('Subject'),
],
'#rows' => [],
'#empty' => $this
->t('No emails have been logged'),
],
'pager' => [
'#type' => 'pager',
],
];
foreach ($log_items as $item) {
$url = Url::fromRoute('development_environment.suppressed_email_log', [
'lid' => $item->lid,
]);
$link = Link::fromTextAndUrl($this
->t('View'), $url);
$page['items']['#rows'][] = [
$link,
$this->dateFormatter
->format($item->timestamp, 'short', '', $this->currentUser
->getTimeZone()),
$item->recipient_email,
$item->subject,
];
}
return $page;
}