<?php
declare(strict_types=1);

namespace Drupal\sector_admin_tools\Hook;

use Drupal\Core\Hook\Attribute\Hook;

final class HtmlHook {

  /**
   * Replaces mytheme_preprocess_block().
   * Mirrors the signature of the procedural hook.
   */
  #[Hook('preprocess_html')]
  public function preprocessHtml(array &$variables): void {
    // Example: add a class to a specific block.
    $route = \Drupal::routeMatch()->getRouteObject();
    $is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);

    if ($is_admin === FALSE && \Drupal::currentUser()->isAuthenticated()) {
      $variables['#attached']['library'][] = "sector_admin_tools/toggle";
      $variables['#attached']['library'][] = "sector_admin_tools/gin";
    }
  }
}
