MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

DryRun

MMO\core\helpers · 1 symbole · générée le 30 Nov 2026

class

DryRun

DryRun.php:27

A request made as a dry run: it runs as it would, answers what it would, and changes nothing. Asked by the header

class MMO\core\helpers\DryRun
Espace de noms
MMO\core\helpers
Voir
HEADER (X-MMO-Dry-Run: 1), for the whole request (Application::handle).
The guarantee is the framework's, and fails closed: - a commit is sent as a dry run ([`Commit`](https://mmoframework.fr/documentation/mmo.core/php/events/Commit.md#commit)): every repository skips it, and what it would have saved is recorded; - a write that does not go through a commit (a driver's insert, an index, a drop) stops the request: [`Guard`](https://mmoframework.fr/documentation/mmo.core/php/helpers/DryRun.md#dryrun-guard) throws [`eDryRun`](https://mmoframework.fr/documentation/mmo.core/php/exceptions/eDryRun.md#edryrun) (409) rather than let it happen; - what would leave the application (a mail, an outside call, a job, a file kept) is not done, and recorded ([`Record`](https://mmoframework.fr/documentation/mmo.core/php/helpers/DryRun.md#dryrun-record)) by whoever would have done it; - the journals (who read what, the log) are still written, marked `dryRun`: they are evidence, not the data. What was recorded goes to the answer: its `meta.dryRun` and the header `X-MMO-Dry-Run: applied`. The entities it changed are then discarded by their repository ([`aRepository::discardChanges`](https://mmoframework.fr/documentation/mmo.core/php/classes/aRepository.md#arepository-discardchanges), [`Stop`](https://mmoframework.fr/documentation/mmo.core/php/helpers/DryRun.md#dryrun-stop)): a creation forgotten, an entity of the store read again from it -- no commit later in the process saves them.
if (\MMO\dryRun()) {DryRun::Record('mails', ['to' => $to, 'subject' => $subject]); return;}DryRun::Guard($this, 'drop collection [{collection}]', ['collection' => $name]);

Index

HEADERThe request's header asking a dry run, 1
active static
entities static
report static
DescribeEntity($entity) static
Guard($origin, $what, $context) staticStop a write that cannot be simulated, when a dry run is on.
IsActive() static
Outside($fn) staticRun $fn as outside the dry run: for a security record only -- a session's token refreshed, which the request needs to authenticate -- never for the data.
Plain($value) static
Record($kind, $what) staticRecord what would have been done, when a dry run is on (nothing otherwise).
RecordEntity($entity) staticRecord an entity a commit would have saved (Commit::dispatch), to say it and forget it.
Report() static
Start() staticStart a dry run: until Stop, nothing is written.
Stop() staticEnd the dry run.

Constantes1

HEADER

The request's header asking a dry run, 1

const HEADER = 'X-MMO-Dry-Run'

Propriétés3

active

static
protected static bool $active = false
Type
bool

entities

static
protected static array $entities = []
Type
array

report

static
protected static array $report = []
Type
array

Méthodes10

DescribeEntity($entity)

staticDryRun.php:130
static function DescribeEntity(MMO\core\interfaces\iEntity $entity): ?array
$entityiEntityan entity a commit would save
retournenull | arraystring, class: string, action: string, changes?: array<string, mixed>} what it would do to it, null when nothing

Guard($origin, $what, $context)

staticDryRun.php:121

Stop a write that cannot be simulated, when a dry run is on.

static function Guard(object|string $origin, string $what, array $context = []): void
$originobject | stringwho would write
$whatstringthe write, a message's format (drop collection [{collection}])
$context = []array
retournevoid
lève(409) when a dry run is on

IsActive()

staticDryRun.php:96
static function IsActive(): bool
retourneboolwhether the current request is a dry run

Outside($fn)

staticDryRun.php:88

Run $fn as outside the dry run: for a security record only -- a session's token refreshed, which the request needs to authenticate -- never for the data. Its commit saves every entity pending then: call it before the request's work.

static function Outside(callable $fn): mixed
$fncallable
retournemixedwhat $fn answers
DryRun::Outside(fn () => \MMO\commit($this));

Plain($value)

staticDryRun.php:147
protected static function Plain(mixed $value): mixed
$valuemixeda value of an entity
retournemixedthe same as JSON shows it, short: an entity by its uid, a date in ISO 8601

Record($kind, $what)

staticDryRun.php:110

Record what would have been done, when a dry run is on (nothing otherwise).

static function Record(string $kind, array $what): void
$kindstringcommits, mails, files, calls, jobs...
$whatarray
retournevoid

RecordEntity($entity)

staticDryRun.php:73

Record an entity a commit would have saved (Commit::dispatch), to say it and forget it.

static function RecordEntity(MMO\core\interfaces\iEntity $entity): void
$entityiEntity
retournevoid

Report()

staticDryRun.php:101
static function Report(): array
retournearraylist<array<string, mixed>>> what was recorded so far

Start()

staticDryRun.php:40

Start a dry run: until Stop, nothing is written.

static function Start(): void
retournevoid

Stop()

staticDryRun.php:50

End the dry run.

static function Stop(): array
retournearraylist<array<string, mixed>>> what it recorded