Page callback: Presents the site-wide contact form.
Drupal\contact\Plugin\Core\Entity\Category $category: (optional) The contact category to use.
\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
contact_site_form_submit()
function contact_site_page(Category $category = NULL) {
// Check if flood control has been activated for sending e-mails.
if (!user_access('administer contact forms')) {
contact_flood_control();
}
if (!isset($category)) {
$categories = entity_load_multiple('contact_category');
$default_category = config('contact.settings')
->get('default_category');
if (isset($categories[$default_category])) {
$category = $categories[$default_category];
}
else {
if (user_access('administer contact forms')) {
drupal_set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array(
'@add' => url('admin/structure/contact/add'),
)), 'error');
return array();
}
else {
throw new NotFoundHttpException();
}
}
}
$message = entity_create('contact_message', array(
'category' => $category
->id(),
));
return entity_get_form($message);
}