The engine has no word for what a booking consumes, so core picked one, and picked it inconsistently. Some strings say places, some say units, and neither is right for every resource: a hall sells places, a refuge sells nights or simply bookings, a bike hire sells bikes. Worse, a place is the name of a specific bookable thing that the dedicated yoyaku_placement module provides, so core naming its generic quantity that way borrows a word it does not own.
Today, counting only the quantity noun and not the verb or the placement seam:
src/Entity/Booking.php:73describes quantity as the number of places this booking consumes.src/Entity/BookingTariff.php:77andsrc/Entity/BookingSlotTariff.php:69describe a quota in places.src/TransactionSummary.php:475renders one place, or a count of places.src/Plugin/ConstraintPolicy/TransactionQuantityLimit.php:73says in places and not in bookings, while its own refusal says units.src/Entity/BookingResource.php:97says one booking per unit.
Proposed resolution
Make the unit a plugin type, and let a resource or a resource type name which one it sells.
- A
BookingUnitplugin, discovered by attribute as the other plugin types here are, owning its own singular and plural wording so that no call site writes a plural itself. That wording lives in the module providing the plugin and is translated through that module's .po file. A free text label on the resource could not do this: plural forms cannot be expressed in Config Translation, so a site typing its own noun would get 4 place where French wants 4 places. - Core ships the neutral default and nothing else. The
placeunit ships inyoyaku_placement, the module named after it, so the word leaves the engine entirely. - A custom module adds a unit by adding a plugin, with no engine change. That is the point: night, ticket, session, bike, whatever a site sells.
- A
booking_unitsetting on the resource type, overridable on the resource, empty meaning inherit. This mirrorsbooking_mode, which already reads leave empty to inherit the resource type. - A call site holding a resource asks it for its unit. One that does not, such as a base field description on an entity that knows no resource, keeps the neutral wording.
A constraint policy already lets an operator word a refusal themselves through its message setting, so the unit gives those a better default rather than replacing that.
Remaining
Worth deciding here: whether the neutral default is called a unit, and whether a resource that runs in a venue should default to the place unit rather than having to be set to it, since the placement layer already knows.
Related: #3614828: Add a per-booker limit that sums units across everything it reaches uses the neutral wording in the strings it touches, so its per-booker limit is one of the call sites this converts.
Issue fork yoyaku-3614854
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mably commentedComment #5
mably commented