function contact_flood_control

Throws an exception if the current user is not allowed to submit a contact form.

Throws

\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

See also

contact_site_page()

contact_personal_page()

2 calls to contact_flood_control()
contact_personal_page in drupal/core/modules/contact/contact.pages.inc
Page callback: Form constructor for the personal contact form.
contact_site_page in drupal/core/modules/contact/contact.pages.inc
Page callback: Presents the site-wide contact form.

File

drupal/core/modules/contact/contact.pages.inc, line 92
Page callbacks for the Contact module.

Code

function contact_flood_control() {
  $config = config('contact.settings');
  $limit = $config
    ->get('flood.limit');
  $interval = $config
    ->get('flood.interval');
  if (!Drupal::service('flood')
    ->isAllowed('contact', $limit, $interval)) {
    drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array(
      '%limit' => $limit,
      '@interval' => format_interval($interval),
    )), 'error');
    throw new AccessDeniedHttpException();
  }
}