Oihana PHP Arango

ModelOperation uses ConstantsTrait

FinalYes

The enumeration of the model calls a controller announces to its lifecycle hooks.

Travels in the init under Arango::OPERATION, so beforeModelCall() and afterModelCall() — one pair for every verb — can tell which call they are serving. They could not before: a PATCH reaches beforeModelCall() three times (probe, write, read-back), getMethod() answers PATCH to all three, and the probe and the read-back carry the same init keys.

Named after what the model does, never after the HTTP verb — that is precisely the distinction the verb cannot make. PUT and PATCH share one call site and split into self::REPLACE and self::UPDATE; POST announces self::INSERT and then self::GET.

⚠ It names the operation the caller asked for, not every round trip to the database. list() runs its count, its facet counts and its bounds under the same init; delete() runs its existence probe under the init of the deletion, on purpose — a probe and a write that could disagree on scope are worse than one announcement.

⚠ Three read-shaped values, and they are not interchangeable. self::EXIST is a probe (the model's exist(), answering a boolean); self::GET is a read of one document; a read that follows a write is a GET too, flagged with Arango::AFTER_WRITE rather than given a value of its own — a hook scoping "every read" must not be able to forget it.

Tags
example
protected function beforeModelCall( ?Request $request , array &$init ) : void
{
    parent::beforeModelCall( $request , $init ) ;

    if ( ( $init[ Arango::OPERATION ] ?? null ) === ModelOperation::INSERT )
    {
        // The real insertion — not the read that hands the document back.
    }
}
since
1.6.0
author

Marc Alcaraz

Table of Contents

Constants

COUNT  : string = 'count'
A per-group or whole-collection count — the model's `count()`.
DELETE  : string = 'delete'
A removal — the model's `delete()`, or an edge removal.
EXIST  : string = 'exist'
An existence probe — the model's `exist()`, which answers a boolean and reads no document. A hook that shapes a projection has nothing to do here; a hook that poses a scope has everything to do here, since the probe is what turns an out-of-scope document into a `404`.
GET  : string = 'get'
The read of a single document — the model's `get()`.
INSERT  : string = 'insert'
A creation — the model's `insert()`.
LAST  : string = 'last'
The most recent document — the model's `last()`.
LIST  : string = 'list'
A listing — the model's `list()`, and the counts and bounds it answers with.
REPLACE  : string = 'replace'
A full overwrite — the model's `replace()`, reached through `PUT`.
TRAVERSE  : string = 'traverse'
A graph traversal answering the vertices around one document.
TRAVERSE_FIRST  : string = 'traverseFirst'
The same traversal, answering only its first vertex.
UPDATE  : string = 'update'
A partial write — the model's `update()`, reached through `PATCH`.

Constants

COUNT

A per-group or whole-collection count — the model's `count()`.

public string COUNT = 'count'

DELETE

A removal — the model's `delete()`, or an edge removal.

public string DELETE = 'delete'

Covers the existence probe that precedes it: both run under one init so they cannot disagree on the scope a hook poses.

EXIST

An existence probe — the model's `exist()`, which answers a boolean and reads no document. A hook that shapes a projection has nothing to do here; a hook that poses a scope has everything to do here, since the probe is what turns an out-of-scope document into a `404`.

public string EXIST = 'exist'

GET

The read of a single document — the model's `get()`.

public string GET = 'get'

Also the read a controller runs after a write to hand the document back through the projection, which is flagged with Arango::AFTER_WRITE: it is a get in every respect, and a hook that scopes reads must reach it too.

INSERT

A creation — the model's `insert()`.

public string INSERT = 'insert'

LAST

The most recent document — the model's `last()`.

public string LAST = 'last'

LIST

A listing — the model's `list()`, and the counts and bounds it answers with.

public string LIST = 'list'

REPLACE

A full overwrite — the model's `replace()`, reached through `PUT`.

public string REPLACE = 'replace'

TRAVERSE

A graph traversal answering the vertices around one document.

public string TRAVERSE = 'traverse'

Neither self::LIST nor self::GET: the call goes to the edges model, not to the controller's own, and no FILTER over the collection would describe it.

TRAVERSE_FIRST

The same traversal, answering only its first vertex.

public string TRAVERSE_FIRST = 'traverseFirst'

UPDATE

A partial write — the model's `update()`, reached through `PATCH`.

public string UPDATE = 'update'
On this page

Search results