class StarkTestThemeHooks
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/stark_test/src/Hook/StarkTestThemeHooks.php \Drupal\stark_test\Hook\StarkTestThemeHooks
Hook implementations for stark_test.
Hierarchy
- class \Drupal\stark_test\Hook\StarkTestThemeHooks
Expanded class hierarchy of StarkTestThemeHooks
File
-
core/
modules/ system/ tests/ modules/ stark_test/ src/ Hook/ StarkTestThemeHooks.php, line 12
Namespace
Drupal\stark_test\HookView source
class StarkTestThemeHooks {
/**
* Implements hook_preprocess_field_multiple_value_form().
*/
public function preprocessFieldMultipleValueForm(&$variables) : void {
// Set test multiple value form field to disabled.
if ($variables["element"]["#field_name"] === "field_multiple_value_form_field") {
$variables['element']['#disabled'] = TRUE;
}
}
/**
* Implements hook_preprocess_html().
*/
public function preprocessHtml(&$variables) : void {
$variables['#attached']['library'][] = 'stark_test/log-errors';
}
/**
* Implements hook_preprocess_menu().
*/
public function preprocessMenu(array &$variables) : void {
$this->setActiveTrailClass($variables['items']);
}
/**
* Recursively adds the active trail class to menu items.
*
* @param array $items
* Menu items array, possibly nested via 'below'.
*/
private function setActiveTrailClass(array $items) : void {
foreach ($items as $item) {
if (!empty($item['in_active_trail'])) {
$item['attributes']->addClass('menu__item--active-trail');
}
if (!empty($item['below'])) {
$this->setActiveTrailClass($item['below']);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.