-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtla_bootstrap_sass.theme
executable file
·76 lines (71 loc) · 2.54 KB
/
tla_bootstrap_sass.theme
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
74
75
76
<?php
/**
* @file
* Functions to support theming in the SASS Starterkit subtheme.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\user\Entity\User;
use Drupal\Core\Cache\CacheableMetadata;
/**
* Implements hook_form_system_theme_settings_alter() for settings form.
*
* Replace Barrio setting options with subtheme ones.
*/
function tla_bootstrap_sass_form_system_theme_settings_alter(&$form, FormStateInterface $form_state)
{
$form['components']['navbar']['bootstrap_barrio_navbar_top_background']['#options'] = array(
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
'bg-white' => t('White'),
'bg-transparent' => t('Transparent'),
);
$form['components']['navbar']['bootstrap_barrio_navbar_background']['#options'] = array(
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
'bg-white' => t('White'),
'bg-transparent' => t('Transparent'),
);
}
/**
* Implements hook_preprocess_HOOK() for menu.html.twig.
*/
function tla_bootstrap_sass_preprocess_block(&$variables)
{
if ($variables['plugin_id'] === 'system_menu_block:account') {
$user = User::load(\Drupal::currentUser()->id());
if (user_picture_enabled() && !$user->user_picture->isEmpty()) {
$uri = $user->user_picture->entity->getFileUri();
$style = \Drupal::entityTypeManager()->getStorage('image_style')->load('account_menu');
$variables['picture'] = $style->buildUrl($uri);
$variables['class'] = 'person';
$cache_metadata = CacheableMetadata::createFromObject($file);
$cache_metadata->applyTo($variables);
} else {
$variables['picture'] = base_path() . \Drupal::service('extension.list.theme')->getPath('tla_bootstrap_sass') . '/images/icon-w-user.svg';
$variables['class'] = 'default';
}
// Force block cache rebuild for every user entity change.
$variables['#cache']['contexts'][] = 'user';
}
}
/**
* Implements hook_form_alter().
*
* Add aria-label to search form for accessibility.
*/
function tla_bootstrap_sass_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
// Check for the specific form ID.
if (strpos($form_id, 'search_form') === 0) {
// Check for the specific form element by name.
if (isset($form['search-textfield'])) {
// Add your attribute to the form element.
$form['search-textfield']['#attributes']['aria-label'] = 'Enter search term';
}
}
}