Oihana PHP Arango

InvalidatesOnWriteTrait uses \oihana\models\traits\signals\HasDeleteSignals, \oihana\models\traits\signals\HasInsertSignals, \oihana\models\traits\signals\HasUpdateSignals

Wires a model's write signals to the cached services it feeds.

Declaring Arango::INVALIDATES on a model definition replaces the hand-rolled decoration a caller would otherwise repeat around every model factory — a copy-paste whose only failure mode is silent staleness.

Documents composes this trait and calls initializeInvalidations() at the end of its constructor, so every Documents / Edges honours the key with no wiring of its own.

Tags
author

Marc Alcaraz

since
1.6.0

Table of Contents

Methods

initializeInvalidations()  : static
Connects `afterInsert` / `afterUpdate` / `afterDelete` to the declared services.

Methods

initializeInvalidations()

Connects `afterInsert` / `afterUpdate` / `afterDelete` to the declared services.

public initializeInvalidations(array<string, mixed> $init, ContainerInterface $container) : static

Called at the end of the Documents constructor, AFTER the signals exist — initializeDocumentsMethods() creates them.

The closure resolves each service from the container at EMISSION time, not at boot: a dependent typically depends on this very model, and an eager resolution here would be circular. By the time a write fires the signal, the model is fully built.

Parameters
$init : array<string, mixed>

The model init.

$container : ContainerInterface

The DI container.

Return values
static
On this page

Search results