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 |
<?php
xp_signal(XP_SIG('foo'), function(\XPSPL\SIG $signal){
$a = xp_current_signal();
echo $a->get_index();
});
The above code will output.
foo
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