\Drupal\strata\Storage ObjectKeys

The key namespace one store writes inside.

Every key the engine names is relative to the store root, and the provider puts it under _strata/<site-id>/ so a bucket or a container can hold two sites and neither sees the other in a listing. The prefix goes on the way out and comes off the way back, in one place, because a provider that adds it in put() and forgets it in list() reports keys nothing can read.

A key arrives from a manifest and a manifest can be tampered with, so .., . and empty segments are refused by name rather than normalised away.

Summary

Methods
Properties
Constants
__construct
resolve
scope
normalize
strip
prefix
RESERVED_SUFFIX
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Constant

RESERVED_SUFFIX

RESERVED_SUFFIX = '.tmp'

Suffix that marks a write in progress rather than an object.

Reserved because a local staging tier writes <key>.tmp while a body is in flight, and a manifest naming that key would collide with a partial write.

Properties

$prefix

$prefix : string

The prefix with no leading slash and exactly one trailing slash, or an empty string.

Type

string

Methods

__construct()

__construct(string  $prefix = '') : mixed

Constructs a key namespace.

Parameters

string $prefix

Prefix every key sits under, normalised to end in a slash. An empty string writes at the root of the store.

Returns

mixed —

resolve()

resolve(string  $key) : string

Turns a caller's key into the key the endpoint sees.

Parameters

string $key

Object key relative to the store root.

Throws

\InvalidArgumentException

When the key is empty, contains a traversal or empty segment or a null byte, or carries the suffix reserved for a write in progress.

Returns

string —

The key with ObjectKeys::$prefix in front of it.

scope()

scope(string  $prefix) : string

A listing prefix, which unlike a key may be empty and names no object.

Parameters

string $prefix

Key prefix relative to the store root.

Returns

string —

The prefix with ObjectKeys::$prefix in front of it.

normalize()

normalize(string  $key) : string

Strips leading and trailing slashes from a key.

Parameters

string $key

The key.

Returns

string —

The key with no leading or trailing slash.

strip()

strip(string  $key) : string

Removes the store prefix from a key the endpoint reported.

Parameters

string $key

A key or common prefix as the endpoint named it.

Returns

string —

The key the engine knows it by.