Issue #3622847: Attach the Booking toolbar icon from the toolbar, move Booking to the front, and measure the codebase on a tag
Closes [#3622847].
What changes
BookingUiHooks::pageAttachments() attached the toolbar icon's stylesheet after guessing, from the current user's permissions, whether there was a toolbar to style. The guess was wrong in both directions: access toolbar does not exist on a site without the toolbar module, and user 1 is answered yes to every permission there is, so the account most likely to be looking was served a toolbar stylesheet on a site with no toolbar -- and on every page, rather than only the pages that have one.
hook_toolbar_alter() runs inside Toolbar::preRenderToolbar(), so it is unreachable without the module and never fires on a request that is not building a toolbar. The toolbar's own cacheability covers it, so the user.permissions cache context goes away with the guess, and currentUser -- injected for that hook alone -- goes with it.
The library lands on $items['administration']['tray'], guarded: a user with a toolbar but no administration menu is not shown the Booking link either, so there would be nothing to style.
Booking also moves to weight -50, to the front, before the sections a site is built with: taking a booking is the work the site exists to do, opened many times a day, while Structure and Appearance are opened while building it and rarely after. kessai's Payments takes -30 and follows it. DefaultMenuLinkTreeManipulators::generateIndexAndSort() keys on (50000 + weight) . ' ' . title . ' ' . plugin_id, and that title is the translated one, so a link tied with Configuration at 0 reorders with the interface language. kessai's Payments takes 7 and follows this one ([#3621929]).
Tests
ToolbarIconTest covers the pair of strings that have to agree and that nothing reads: that the class the stylesheet writes is the class core generates from the link's plugin id, and that the library lands on the administration tray and nowhere else.
Gate
phpcs (Drupal,DrupalPractice, CI's extension list) over the whole project, 0 errors 0 warnings; phpstan level 5 [OK] No errors.
Also here
A metrics job, gated rules: - if: $CI_COMMIT_TAG and allow_failure: true, ported from audit_trail. docs/metrics.md is a snapshot, regenerated deliberately rather than kept in step by every merge request, and nothing measured it on a release either.
It measures from git archive into /tmp, because the pipeline builds a whole Drupal underneath the project directory and cloc run in place would count core as well. The diff it prints is not evidence of staleness on its own -- the page counts the file it writes -- so it gates nothing and is there for a maintainer to read. The generator gains METRICS_DATE, which audit_trail's already had, so the re-measurement reproduces the committed page's date rather than reporting the day it ran as the only difference.