Oihana PHP System

HasReplaceSignals

Provides replace-related signals.

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

Signals:

  • $beforeReplace: Emitted before the replace occurs.
  • $afterReplace: Emitted after the replace is complete.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$afterReplace  : Signal|null
Signal emitted after a document has been replaced.
$beforeReplace  : Signal|null
Signal emitted before a document is replaced.

Methods

initializeReplaceSignals()  : static
Initializes the replace-related signals.
releaseReplaceSignals()  : static
Release the replace-related signals.

Properties

$afterReplace

Signal emitted after a document has been replaced.

public Signal|null $afterReplace = null

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

$beforeReplace

Signal emitted before a document is replaced.

public Signal|null $beforeReplace = null

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

Methods

initializeReplaceSignals()

Initializes the replace-related signals.

public initializeReplaceSignals() : static

Creates new Signal instances for $beforeReplace and $afterReplace.

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

Returns $this for method chaining.

releaseReplaceSignals()

Release the replace-related signals.

public releaseReplaceSignals() : static

Nullify and disconnect the afterReplace and beforeInsert signals.

Return values
static

Returns $this for method chaining.


        
On this page

Search results