Oihana PHP System

HasTruncateSignals

Provides truncated signals.

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

Signals:

  • $beforeTruncate: Emitted before the update occurs.
  • $afterTruncate: Emitted after the update is complete.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$afterTruncate  : Signal|null
Signal emitted after a collection has been truncated.
$beforeTruncate  : Signal|null
Signal emitted before a collection is truncated.

Methods

initializeTruncateSignals()  : static
Initializes the truncated-related signals.
releaseTruncateSignals()  : static
Release the truncated-related signals.

Properties

$afterTruncate

Signal emitted after a collection has been truncated.

public Signal|null $afterTruncate = null

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

$beforeTruncate

Signal emitted before a collection is truncated.

public Signal|null $beforeTruncate = null

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

Methods

initializeTruncateSignals()

Initializes the truncated-related signals.

public initializeTruncateSignals() : static

Creates new Signal instances for $beforeTruncate and $afterTruncate.

Tags
example
$document->initializeTruncateSignals()
         ->beforeTruncate?->connect(fn($doc) => echo "About to truncate the collection");
Return values
static

Returns $this for method chaining.

releaseTruncateSignals()

Release the truncated-related signals.

public releaseTruncateSignals() : static

Nullify and disconnect the afterTruncate and beforeTruncate signals.

Return values
static

Returns $this for method chaining.


        
On this page

Search results