SectorRecordWriteService
in package
Sector record write service - full CRUD for GLAM sector records.
A sector record is a QubitInformationObject (source_standard = the sector) plus the sector's primary extension data. The four supported sectors are non-uniform:
library -> library_item table, keyed by information_object_id (NO FK cascade)
dam -> dam_iptc_metadata table, keyed by object_id (NO FK cascade)
museum -> museum_metadata table, keyed by object_id (FK ON DELETE CASCADE)
gallery -> property JSON blob name='galleryData' (property FK cascade)
Create/update upsert the extension (there is no DB unique key on the library/dam link columns, so we select-then-insert/update). Delete removes the non-cascading extension rows explicitly, then deletes the information object (which cascades the museum_metadata / galleryData property / display_object_config rows and the nested-set links).
This centralises write logic that previously lived inline in the sector edit actions (saveLibraryItem / saveIptcMetadataDirectly / saveMuseumData / galleryData saveProperty). Library/DAM plugins are locked, so this lives in the framework.
Tags
Table of Contents
Methods
- create() : int
- Create a sector record: information object (source_standard = sector) + extension.
- delete() : void
- Delete a sector record: extension (explicit where not cascading) + information object.
- museumFormOverridesFromMetadata() : array<string, mixed>
- Reverse of the museum sync: read the canonical museum_metadata row and return its mapped values keyed by the museum-module FORM field names. The museum edit form overlays these onto its ccoData so it shows the same data the readers use (Step 3b). Returns [] when there is no museum_metadata row. materials/techniques are JSON-decoded back to arrays to match the form's ccoData shape.
- read() : array<string|int, mixed>|null
- Read the sector extension for an information object (assoc array, or null).
- supportedSectors() : array<string|int, mixed>
- syncMuseumMetadata() : void
- Sync bridge: mirror the mapped fields of a museum-module edit (ccoData form data) into the canonical museum_metadata table that reports/facets/exports read.
- update() : void
- Update (upsert) the sector extension for an existing information object.
Methods
create()
Create a sector record: information object (source_standard = sector) + extension.
public
create(string $sector, string $title[, array<string|int, mixed> $fields = [] ][, string $culture = 'en' ]) : int
Parameters
- $sector : string
-
library|dam|museum|gallery
- $title : string
-
descriptive title
- $fields : array<string|int, mixed> = []
-
sector extension fields (column => value, or JSON keys for gallery)
- $culture : string = 'en'
Return values
int —the new information_object id
delete()
Delete a sector record: extension (explicit where not cascading) + information object.
public
delete(int $ioId, string $sector) : void
Parameters
- $ioId : int
- $sector : string
museumFormOverridesFromMetadata()
Reverse of the museum sync: read the canonical museum_metadata row and return its mapped values keyed by the museum-module FORM field names. The museum edit form overlays these onto its ccoData so it shows the same data the readers use (Step 3b). Returns [] when there is no museum_metadata row. materials/techniques are JSON-decoded back to arrays to match the form's ccoData shape.
public
museumFormOverridesFromMetadata(int $ioId) : array<string, mixed>
Parameters
- $ioId : int
Return values
array<string, mixed> —form-field => canonical value
read()
Read the sector extension for an information object (assoc array, or null).
public
read(int $ioId, string $sector) : array<string|int, mixed>|null
Parameters
- $ioId : int
- $sector : string
Return values
array<string|int, mixed>|nullsupportedSectors()
public
static supportedSectors() : array<string|int, mixed>
Return values
array<string|int, mixed>syncMuseumMetadata()
Sync bridge: mirror the mapped fields of a museum-module edit (ccoData form data) into the canonical museum_metadata table that reports/facets/exports read.
public
syncMuseumMetadata(int $ioId, array<string|int, mixed> $formData) : void
Authoritative for mapped columns (non-empty values overwrite). This is safe because the museum form loads those fields FROM museum_metadata via museumFormOverridesFromMetadata() (Step 3b), so a submitted value is always the canonical value or a deliberate edit, never a stale ccoData placeholder. Empty form values are skipped (a blank field never clears canonical data), and the ~70 columns the form does not expose are never touched. New records get all mapped values. Additive/reversible; the ccoData blob is left intact.
Parameters
- $ioId : int
-
information object id
- $formData : array<string|int, mixed>
-
the museum module's ccoData field array
update()
Update (upsert) the sector extension for an existing information object.
public
update(int $ioId, string $sector, array<string|int, mixed> $fields[, string $culture = 'en' ]) : void
Parameters
- $ioId : int
- $sector : string
- $fields : array<string|int, mixed>
- $culture : string = 'en'