This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
govcms.profile
73 lines (65 loc) · 2.56 KB
/
govcms.profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @file
* Enables modules and site configuration for the govCMS profile.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\contact\Entity\ContactForm;
/**
* Implements hook_form_FORM_ID_alter() for install_configure_form().
*
* Allows the profile to alter the site configuration form.
*/
function govcms_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
// Add a placeholder as example that one can choose an arbitrary site name.
$form['site_information']['site_name']['#attributes']['placeholder'] = t('GovCMS');
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function govcms_form_contact_message_contact_form_alter(&$form, FormStateInterface $form_state) {
$form['actions']['preview']['#access'] = FALSE;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function govcms_form_user_login_form_alter(&$form, &$form_state) {
$form['#attributes']['autocomplete'] = 'off';
}
/**
* Implements hook_page_attachments_alter().
*/
function govcms_page_attachments_alter(array &$page) {
foreach ($page['#attached']['html_head'] as $key => $value) {
if ($value[1] == 'system_meta_generator') {
$page['#attached']['html_head'][$key][0]['#attributes']['content'] = 'Drupal 8 (http://drupal.org) + GovCMS (http://govcms.gov.au)';
}
}
}
/**
* Implements hook_system_breadcrumb_alter().
*/
function govcms_system_breadcrumb_alter(Breadcrumb $breadcrumb, RouteMatchInterface $route_match, array $context) {
// Append the current page title to the breadcrumb for non-admin routes.
if (!empty($route_match->getRouteObject()) && $breadcrumb && !\Drupal::service('router.admin_context')->isAdminRoute()) {
$title = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route_match->getRouteObject());
if (!empty($title)) {
$breadcrumb->addLink(Link::createFromRoute($title, '<none>'));
}
$breadcrumb->addCacheContexts(['route']);
}
}
/**
* Implements hook_field_widget_form_alter().
*/
function govcms_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
// In Drupal 7 `hook_field_widget_form_alter` could be implemented by the
// theme, but in Drupal 8 this hook changed to being module-only. This hook
// can be critical for improving the editor experience for things like
// paragraphs. Implementing themes can access the plugin ID via
// $context['widget']->getPluginId().
\Drupal::theme()->alter(['field_widget_form'], $element, $form_state, $context);
}