Oihana PHP Arango

ArangoPreservesTrait

Reads and validates the `[arango.preserves]` config section — the rules of the `preserve` and `reinject` actions.

One table per collection (edge collections included), keyed by its name :

[arango.preserves.articles]
filters    = { _key = "string" }
filter     = '{"key":"_key","op":"nsw","val":"src:"}'
maxPercent = 50   # optional, 50 by default

The rule says which documents of the collection belong to this machine — a property of the local database, like [arango.restore].protected, which is why it lives outside the dump/restore profiles. Everything that cannot be read is refused before anything is written ; see preserveFilters().

Tags
since
1.10.0
author

Marc Alcaraz

Table of Contents

Properties

$preserves  : array<string|int, mixed>
The declared rules, from the `[arango.preserves]` config section.

Methods

initializeArangoPreserves()  : static
Captures the `[arango.preserves]` config section from the init array.
preserveCount()  : int
Runs a query that returns a single number, and returns it.
preserveFilters()  : array<string, PreserveFilter>
The compiled rules of the requested collections, keyed and sorted by name.
preserveFilter()  : PreserveFilter
Validates one `[arango.preserves.<collection>]` rule and compiles it.

Properties

$preserves

The declared rules, from the `[arango.preserves]` config section.

protected array<string|int, mixed> $preserves = []

Methods

initializeArangoPreserves()

Captures the `[arango.preserves]` config section from the init array.

public initializeArangoPreserves([array<string|int, mixed> $init = [] ]) : static
Parameters
$init : array<string|int, mixed> = []
Return values
static

preserveCount()

Runs a query that returns a single number, and returns it.

protected preserveCount(Database $db, AqlQuery $query) : int
Parameters
$db : Database

The database to query.

$query : AqlQuery

A query returning one integer.

Return values
int

preserveFilters()

The compiled rules of the requested collections, keyed and sorted by name.

protected preserveFilters([array<int, string> $only = [] ]) : array<string, PreserveFilter>
Parameters
$only : array<int, string> = []

The collections named on the command line ; empty means every declared rule.

Tags
throws
InvalidArgumentException

When no rule is declared, a named collection has no rule, or a rule cannot be read.

Return values
array<string, PreserveFilter>

preserveFilter()

Validates one `[arango.preserves.<collection>]` rule and compiles it.

private preserveFilter(string $collection, mixed $definition) : PreserveFilter
Parameters
$collection : string

The collection the rule is declared for.

$definition : mixed

The rule as the configuration gives it.

Tags
throws
InvalidArgumentException

When the rule cannot be read.

Return values
PreserveFilter
On this page

Search results