\Drupal\strata\Capture KeyValueCapture

Records key-value writes by wrapping one collection's store.

Key-value has no events either, and unlike state it comes from a factory, so the factory is decorated and each store it hands out is wrapped in one of these.

The subject is collection:key, so two collections holding the same key are two subjects and a restore of one does not touch the other.

Summary

Methods
Properties
Constants
__construct
getCollectionName
has
get
getMultiple
getAll
getAllKeys
set
setIfNotExists
setMultiple
rename
delete
deleteMultiple
deleteAll
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
recorder
covers
subject
resolved
inner
recorder
collection
No private constants found

Properties

$resolved

$resolved : ?\Drupal\strata\Capture\KeyRecorder

The recorder once a closure has been called, so it is resolved once per store.

Type

KeyRecorder|null

$inner

$inner : \Drupal\Core\KeyValueStore\KeyValueStoreInterface

Type

KeyValueStoreInterface

$recorder

$recorder : \Drupal\strata\Capture\KeyRecorder|\Closure

Type

KeyRecorder|Closure

$collection

$collection : string

Type

string

Methods

__construct()

__construct(\Drupal\Core\KeyValueStore\KeyValueStoreInterface  $inner, \Drupal\strata\Capture\KeyRecorder|\Closure  $recorder, string  $collection) : mixed

Constructs the decorator.

Parameters

\Drupal\Core\KeyValueStore\KeyValueStoreInterface $inner

The store being wrapped.

\Drupal\strata\Capture\KeyRecorder|\Closure $recorder

Journals each write, or a closure returning one.

string $collection

The collection name, which becomes part of the subject path.

Returns

mixed —

getCollectionName()

getCollectionName() : mixed

{@inheritdoc}

Returns

mixed —

has()

has(mixed  $key) : mixed

{@inheritdoc}

Parameters

mixed $key

Returns

mixed —

get()

get(mixed  $key, mixed  $default = null) : mixed

{@inheritdoc}

Parameters

mixed $key
mixed $default

Returns

mixed —

getMultiple()

getMultiple(array  $keys) : mixed

{@inheritdoc}

Parameters

array $keys

Returns

mixed —

getAll()

getAll() : mixed

{@inheritdoc}

Returns

mixed —

getAllKeys()

getAllKeys() : iterable

{@inheritdoc}

Returns

iterable —

set()

set(mixed  $key, mixed  $value) : mixed

{@inheritdoc}

Parameters

mixed $key
mixed $value

Returns

mixed —

setIfNotExists()

setIfNotExists(mixed  $key, mixed  $value) : mixed

{@inheritdoc}

Recorded only when the write actually happened. The whole point of this method is that it does nothing when the key is taken, and recording a change that did not occur would put a value in the history that was never in the site.

Parameters

mixed $key
mixed $value

Returns

mixed —

setMultiple()

setMultiple(array  $data) : mixed

{@inheritdoc}

Parameters

array $data

Returns

mixed —

rename()

rename(mixed  $key, mixed  $new_key) : mixed

{@inheritdoc}

Parameters

mixed $key
mixed $new_key

Returns

mixed —

delete()

delete(mixed  $key) : mixed

{@inheritdoc}

Parameters

mixed $key

Returns

mixed —

deleteMultiple()

deleteMultiple(array  $keys) : mixed

{@inheritdoc}

Parameters

array $keys

Returns

mixed —

deleteAll()

deleteAll() : mixed

{@inheritdoc}

Every key is recorded individually rather than as one collection-level operation, because a restore puts keys back one at a time and an operation naming the collection would give it nothing to put back.

Returns

mixed —

recorder()

recorder() : \Drupal\strata\Capture\KeyRecorder

The recorder, resolved on first use.

A closure rather than a recorder is what a site is wired with, because keyvalue is asked for a store while the container is still compiling and a recorder cannot be built then. Reading a value never resolves it; only a write does, by which time the container is finished.

Returns

\Drupal\strata\Capture\KeyRecorder —

The recorder.

covers()

covers() : bool

Whether this collection's writes are recorded.

Returns

bool —

TRUE when the key-value realm is captured.

subject()

subject(string  $key) : string

The subject key one entry is recorded under.

Parameters

string $key

The entry's key.

Returns

string —

Shaped collection:key.