Oihana PHP System

HasUpsertSignals

Provides upsert-related signals.

This trait defines signals that are emitted before and after a document is upserted, allowing observers to react to the update event.

Signals:

  • $beforeUpsert: Emitted before the update occurs.
  • $afterUpsert: Emitted after the update is complete.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$afterUpsert  : Signal|null
Signal emitted after a document has been upserted.
$beforeUpsert  : Signal|null
Signal emitted before a document is upserted.

Methods

initializeUpsertSignals()  : static
Initializes the upsert-related signals.
releaseUpsertSignals()  : static
Release the upsert-related signals.

Properties

$afterUpsert

Signal emitted after a document has been upserted.

public Signal|null $afterUpsert = null

Observers connected to this signal receive the upserted document and optional context.

$beforeUpsert

Signal emitted before a document is upserted.

public Signal|null $beforeUpsert = null

Observers connected to this signal receive the document that is about to be updated.

Methods

initializeUpsertSignals()

Initializes the upsert-related signals.

public initializeUpsertSignals() : static

Creates new Signal instances for $beforeUpsert and $afterUpsert.

Tags
example
$document->initializeUpsertSignals()
         ->beforeUpsert?->connect(fn($doc) => echo "About to upsert {$doc->id}");
Return values
static

Returns $this for method chaining.

releaseUpsertSignals()

Release the upsert-related signals.

public releaseUpsertSignals() : static

Nullify and disconnect the afterUpsert and beforeUpsert signals.

Return values
static

Returns $this for method chaining.


        
On this page

Search results