class TestHtmxHooks

Same name and namespace in other branches
  1. main core/modules/system/tests/modules/test_htmx/src/Hook/TestHtmxHooks.php \Drupal\test_htmx\Hook\TestHtmxHooks

Hooks for the test_htmx module.

Hierarchy

Expanded class hierarchy of TestHtmxHooks

File

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

Namespace

Drupal\test_htmx\Hook
View source
class TestHtmxHooks {
  public function __construct(protected RouteMatchInterface $routeMatch) {
  }
  
  /**
   * Implements hook_preprocess_HOOK() for html.
   */
  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';
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary
TestHtmxHooks::boost public function Implements hook_preprocess_HOOK() for html.
TestHtmxHooks::__construct public function

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