function hook_mail_safety_table_structure_alter in Mail Safety 8
Same name and namespace in other branches
- 7.2 mail_safety.api.php \hook_mail_safety_table_structure_alter()
- 7 mail_safety.api.php \hook_mail_safety_table_structure_alter()
Alter the table structure of the mail safety dashboard.
Parameters
array $table_structure: The table structure that will be rendered as table.
1 invocation of hook_mail_safety_table_structure_alter()
- DashboardForm::buildForm in src/
Form/ DashboardForm.php - Form constructor.
File
- ./
mail_safety.api.php, line 75 - Hooks provided by the Mail Safety module.
Code
function hook_mail_safety_table_structure_alter(array $table_structure) {
// Add a new column.
$table_structure['header'][] = [
'data' => t('Files'),
];
// Loop through the mails to add the attachments in the table.
foreach ($table_structure['rows'] as $mail_id => $row) {
$mail = mail_safety_load($mail_id);
if (!empty($mail['mail']['attachments'])) {
$attachments = [];
foreach ($mail['mail']['attachments'] as $attachment) {
$attachments[] = [
'#theme' => 'file_link',
'#file' => $attachment,
];
}
}
$table_structure['rows'][$mail_id]['data'][] = $attachments;
}
return $table_structure;
}