function redirect_404_form_redirect_settings_form_alter in Redirect 8
Implements hook_form_FORM_ID_alter() for system_logging_settings().
File
- modules/
redirect_404/ redirect_404.module, line 34 - Module file for redirect_404.
Code
function redirect_404_form_redirect_settings_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$config = \Drupal::configFactory()
->getEditable('redirect_404.settings');
$row_limits = [
100,
1000,
10000,
100000,
1000000,
];
$form['row_limit'] = [
'#type' => 'select',
'#title' => t('404 error database logs to keep'),
'#default_value' => $config
->get('row_limit'),
'#options' => [
0 => t('All'),
] + array_combine($row_limits, $row_limits),
'#description' => t('The maximum number of 404 error logs to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [
':cron' => Url::fromRoute('system.status')
->toString(),
]),
];
$ignored_pages = $config
->get('pages');
// Add a new path to be ignored, if there is an ignore argument in the query.
if ($path_to_ignore = \Drupal::request()->query
->get('ignore')) {
$ignored_pages .= $path_to_ignore;
}
$form['ignore_pages'] = [
'#type' => 'textarea',
'#title' => t('Pages to ignore'),
'#default_value' => $ignored_pages,
'#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", [
'%user-wildcard' => '/user/*',
'%front' => '<front>',
]),
];
$form['suppress_404'] = [
'#type' => 'checkbox',
'#title' => t("Suppress 'page not found' log messages"),
'#default_value' => $config
->get('suppress_404'),
'#description' => t("Prevents logging 'page not found' events. Can be safely enabled when redirect_404 module is used, which stores them separately, nothing else relies on those messages."),
];
$form['#submit'][] = 'redirect_404_logging_settings_submit';
}