SectorIdentifierService.php
SectorIdentifierService - shared identifier auto-generator for the sector-aware entity create() flows (AtoM-AHG port).
Ported from Heratio's AhgCore\Services\SectorIdentifierService so the
AtoM-AHG sector creates (dam/create etc.) share ONE counter with the
/ahgSettings/sectorNumbering admin page. Both read and write the same
sector__identifier_counter setting in the setting/setting_i18n
table - no more disconnected numbering systems.
Setting key name variants honoured (single-underscore preferred so an
operator save wins over a seed):
sector_identifier_mask_enabled / sector_identifier_mask_enabled
sectoridentifier_mask / sector_identifier_mask
sectoridentifier_counter / sector_identifier_counter
Falls back to a global trio (no sector prefix) when the sector mask is
disabled or empty.
Mask renderer supports AtoM-style %Y% %y% %m% %d% %NNNi% and curly {YYYY} {YY} {MM} {DD} {SECTOR} plus a #+ run; anything else passes through literally.
Counter increment uses optimistic CAS with retries so concurrent creates can't collide on the same number.
Copyright (C) 2026 Johan Pieterse / Plain Sailing Information Systems Licensed under the GNU AGPL v3.