Oihana PHP System

Payload extends Notice

Represents a payload notice emitted by a Signal.

This class encapsulates the details of an event, including:

  • The type of the event ($type).
  • The payload ($data).
  • The target object that triggered the event ($target).
  • Additional contextual information related to the event ($context).

It is typically used as the payload when emitting signals:

$signal->emit( new Payload
(
   type    : 'delete' ,
   data    : [ 'id' => '15151' , 'name' : 'John' ] ,
   target  : $signal
));
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$context  : array<string|int, mixed>
The context of the notice
$data  : string
The message of the notice
$target  : mixed
The target of the notice.
$type  : mixed
The type of the notice.

Methods

__construct()  : mixed
Creates a new Payload.
jsonSerialize()  : array<string|int, mixed>
Serializes the current object into a JSON array.
toArray()  : array<string|int, mixed>
Returns the array representation of the notice object.

Properties

$context

The context of the notice

public array<string|int, mixed> $context

$data

The message of the notice

public string $data

$target

The target of the notice.

public mixed $target

$type

The type of the notice.

public mixed $type

Methods

__construct()

Creates a new Payload.

public __construct(string $type[, string $data = null ][, object|null $target = null ][, array<string|int, mixed> $context = [] ]) : mixed
Parameters
$type : string

The type of the notice.

$data : string = null

The payload entry.

$target : object|null = null

The target of the notice.

$context : array<string|int, mixed> = []

The context of the notice.

jsonSerialize()

Serializes the current object into a JSON array.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
ReflectionException

If reflection fails when accessing properties.

Return values
array<string|int, mixed>

JSON-LD representation of the object.

toArray()

Returns the array representation of the notice object.

public toArray() : array<string|int, mixed>
Tags
throws
ReflectionException
Return values
array<string|int, mixed>

        
On this page

Search results