$inner
$inner : \Drupal\Core\State\StateInterface
Records state writes by wrapping the state service.
State has no events, and it is not a factory, so decoration is the way in. Every read passes straight through; every write is journaled and then delegated.
The old value is read before a write, because the decorator has no other way to tell a create
from an update and because a restore of a create has to know the key did not exist. State handles
~580 operations a day on a 50,000-user site - under 1% of write volume - so one extra read per
write is not a cost worth optimising away, and getMultiple() makes the batch case one query
rather than N.
The whole value is stored rather than a delta. State values are small and structurally arbitrary, so a field-level diff would cost more to compute and store than the value itself.
Both contracts have to be satisfied, not just StateInterface. Core's State extends
CacheCollector, and core calls the collector's own methods on the service by name: the test
runner's RefreshVariablesTrait calls reset() on state with no is_callable guard at all. A
decorator declaring only StateInterface therefore compiles, installs, serves pages, and then
fails the moment anything reaches for the half of the surface the interface does not describe.
$recorder : \Drupal\strata\Capture\KeyRecorder
__construct(\Drupal\Core\State\StateInterface $inner, \Drupal\strata\Capture\KeyRecorder $recorder) : mixed
Constructs the decorator.
| \Drupal\Core\State\StateInterface | $inner | The state service being wrapped. |
| \Drupal\strata\Capture\KeyRecorder | $recorder | Journals each write. |
destruct() : void
{@inheritdoc}
State is a cache collector, and the needs_destruction tag on the service is what makes it
write its collected values out at the end of a request. Decorating the service moves that tag to
this class, so a decorator that did not pass the call through would silently stop state being
persisted at all - a failure that looks like nothing until a value goes missing.
exists(string $key) : bool
Whether a key currently holds a value.
A sentinel is used rather than comparing against NULL, since NULL is a value state can hold and a restore that turned a stored NULL into a missing key would be wrong.
| string | $key | The state key. |
TRUE when the key is set.