Oihana PHP System

HasUpdateSignals

Provides update-related signals.

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

Signals:

  • $beforeUpdate: Emitted before the update occurs.
  • $afterUpdate: Emitted after the update is complete.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$afterUpdate  : Signal|null
Signal emitted after a document has been updated.
$beforeUpdate  : Signal|null
Signal emitted before a document is updated.

Methods

initializeUpdateSignals()  : static
Initializes the update-related signals.
releaseUpdateSignals()  : static
Release the update-related signals.

Properties

$afterUpdate

Signal emitted after a document has been updated.

public Signal|null $afterUpdate = null

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

$beforeUpdate

Signal emitted before a document is updated.

public Signal|null $beforeUpdate = null

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

Methods

initializeUpdateSignals()

Initializes the update-related signals.

public initializeUpdateSignals() : static

Creates new Signal instances for $beforeUpdate and $afterUpdate.

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

Returns $this for method chaining.

releaseUpdateSignals()

Release the update-related signals.

public releaseUpdateSignals() : static

Nullify and disconnect the afterUpdate and beforeUpdate signals.

Return values
static

Returns $this for method chaining.


        
On this page

Search results