class ZoneMetadataService (View source)

The zone metadata rules the editor and the API share: what a kind accepts, who may change it, what the active backend can store, and how a change is persisted and logged. Callers parse their input and word the refusals.

Constants

SUPPORT_SUPPORTED

SUPPORT_UNSUPPORTED_KNOWN

SUPPORT_UNKNOWN

MAX_KIND_LENGTH

Methods

__construct(ZoneMetadataStoreInterface $store, ConfigurationInterface $config, PermissionService $permissions, AuditLoggerInterface $audit, RecordChangeWriterInterface $changeLogger, LoggerInterface|null $logger = null, ZoneCacheFlusherInterface|null $zoneCacheFlusher = null)

No description

static string
normalizeKind(string $kind)

No description

static array
normalizeRows(array $rows)

Trim the submitted rows and drop the ones with no kind or no content, so an add/remove-row editor never produces an empty write.

static array
changedKinds(array $submitted, array $current)

The kinds whose value set differs between two snapshots.

string|null
writeRejection(string $kind)

Why the active store cannot hold this kind (a MetadataDefinitions::REJECT_* code), or null.

string
kindSupport(array $definition, callable $capabilities)

Whether the active store is known to take a version-gated kind: SUPPORT_* constants.

array
load(int $zoneId, string $zoneName)

The zone's metadata rows, sorted by kind. In API mode the zone-object properties that stand in for metadata kinds are folded in.

replaceAll(int $zoneId, string $zoneName, array $rows, int $actingUserId)

Replace the zone's whole metadata set, as the editor does. Every row is checked first, then only the kinds that actually change are gated, so a value set out of band does not lock the editor out of the rest.

replaceKind(int $zoneId, string $zoneName, string $kind, array $values, int $actingUserId)

Set every value of one kind, as the API does.

deleteKind(int $zoneId, string $zoneName, string $kind, int $actingUserId)

Remove every value of one kind, as the API does.

static array
replaceKindIn(array $rows, string $kind, array $values)

The set with every row of one kind replaced by the given values.

Details

__construct(ZoneMetadataStoreInterface $store, ConfigurationInterface $config, PermissionService $permissions, AuditLoggerInterface $audit, RecordChangeWriterInterface $changeLogger, LoggerInterface|null $logger = null, ZoneCacheFlusherInterface|null $zoneCacheFlusher = null)

No description

Parameters

ZoneMetadataStoreInterface $store
ConfigurationInterface $config
PermissionService $permissions
AuditLoggerInterface $audit
RecordChangeWriterInterface $changeLogger
LoggerInterface|null $logger
ZoneCacheFlusherInterface|null $zoneCacheFlusher

static string normalizeKind(string $kind)

No description

Parameters

string $kind

Return Value

string

static array normalizeRows(array $rows)

Trim the submitted rows and drop the ones with no kind or no content, so an add/remove-row editor never produces an empty write.

Parameters

array $rows

Return Value

array

static array changedKinds(array $submitted, array $current)

The kinds whose value set differs between two snapshots.

Parameters

array $submitted
array $current

Return Value

array

string|null writeRejection(string $kind)

Why the active store cannot hold this kind (a MetadataDefinitions::REJECT_* code), or null.

Parameters

string $kind

Return Value

string|null

string kindSupport(array $definition, callable $capabilities)

Whether the active store is known to take a version-gated kind: SUPPORT_* constants.

Parameters

array $definition

A MetadataDefinitions entry

callable $capabilities

Resolved only when support is version-gated

Return Value

string

array load(int $zoneId, string $zoneName)

The zone's metadata rows, sorted by kind. In API mode the zone-object properties that stand in for metadata kinds are folded in.

Parameters

int $zoneId
string $zoneName

Return Value

array

ZoneMetadataResult replaceAll(int $zoneId, string $zoneName, array $rows, int $actingUserId)

Replace the zone's whole metadata set, as the editor does. Every row is checked first, then only the kinds that actually change are gated, so a value set out of band does not lock the editor out of the rest.

Parameters

int $zoneId
string $zoneName
array $rows

Already normalised

int $actingUserId

Return Value

ZoneMetadataResult

ZoneMetadataResult replaceKind(int $zoneId, string $zoneName, string $kind, array $values, int $actingUserId)

Set every value of one kind, as the API does.

Parameters

int $zoneId
string $zoneName
string $kind
array $values
int $actingUserId

Return Value

ZoneMetadataResult

ZoneMetadataResult deleteKind(int $zoneId, string $zoneName, string $kind, int $actingUserId)

Remove every value of one kind, as the API does.

Parameters

int $zoneId
string $zoneName
string $kind
int $actingUserId

Return Value

ZoneMetadataResult

static array replaceKindIn(array $rows, string $kind, array $values)

The set with every row of one kind replaced by the given values.

Parameters

array $rows
string $kind
array $values

Return Value

array