HasDeleteSignals
Provides deletion-related signals.
This trait defines signals that are emitted before and after a document is deleted, allowing observers (slots) to react to these events.
Signals:
$beforeDelete: Emitted before the deletion occurs.$afterDelete: Emitted after the deletion is complete.
Example usage:
$document->initializeDeleteSignals();
$document->beforeDelete?->connect(fn($doc) => echo "About to delete {$doc->id}");
$document->afterDelete?->connect(fn($doc) => echo "Deleted document {$doc->id}");
Tags
Table of Contents
Properties
- $afterDelete : Signal|null
- Signal emitted after a document has been deleted.
- $beforeDelete : Signal|null
- Signal emitted before a document is deleted.
Methods
- initializeDeleteSignals() : static
- Initializes the deletion-related signals.
- releaseDeleteSignals() : static
- Release the deletion-related signals.
Properties
$afterDelete
Signal emitted after a document has been deleted.
public
Signal|null
$afterDelete
= null
Observers connected to this signal receive the deleted document and optional context.
$beforeDelete
Signal emitted before a document is deleted.
public
Signal|null
$beforeDelete
= null
Observers connected to this signal receive the document that is about to be deleted.
Methods
initializeDeleteSignals()
Initializes the deletion-related signals.
public
initializeDeleteSignals() : static
Creates new Signal instances for $beforeDelete and $afterDelete.
Tags
Return values
static —Returns $this for method chaining.
releaseDeleteSignals()
Release the deletion-related signals.
public
releaseDeleteSignals() : static
Nullify and disconnect the $beforeDelete and $afterDelete signals.
Return values
static —Returns $this for method chaining.