function TestHtmxHooks::boost

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/test_htmx/src/Hook/TestHtmxHooks.php \Drupal\test_htmx\Hook\TestHtmxHooks::boost()

Implements hook_preprocess_HOOK() for html.

Attributes

#[Hook('preprocess_html')]

File

core/modules/system/tests/modules/test_htmx/src/Hook/TestHtmxHooks.php, line 22

Class

TestHtmxHooks
Hooks for the test_htmx module.

Namespace

Drupal\test_htmx\Hook

Code

public function boost(array &$variables) : void {
  if ($this->routeMatch
    ->getRouteName() === 'test_htmx.attachments.body') {
    $variables['#attached']['library'][] = 'core/drupal.htmx';
    $variables['attributes']['data-hx-boost'] = 'true';
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.