xp_current_signal

xp_current_signal([$offset = false])

Retrieve the current signal in execution.

Parameters:integer – If a positive offset is given it will return from the top of the signal stack, if negative it will return from the bottom (current) of the stack.
Return type:object \XPSPL\SIG

Example #1 Basic Usage

<?php

xp_signal(XP_SIG('foo'), function(\XPSPL\SIG $signal){
    $a = xp_current_signal();
    echo $a->get_index();
});

The above code will output.

foo

Example #2 Parent Signals

Parent signals can be fetched by using a negative offset < -1.

<?php

// Install a process on the bar SIG
xp_signal(XP_SIG('bar'), function(){
    // Emit foo within bar
    xp_emit(XP_SIG('foo'));
});

// Install a process on the foo SIG
xp_signal(XP_SIG('foo'), function(){
    // Get the parent of foo
    $a = xp_current_signal(-2);
    echo $a->get_index();
});

The above code will output.

bar
Read the Docs v: v5.0.1
Versions
latest
v5.0.1
v5.0.0
v4.0.1
v4.0.0
v3.1.1
v3.1.0
v3.0.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.