\apex\app\msg\objectsevent_response

Creates a EventResponseInterface object, which is used to send back to the front-end software during a RPC call. This is the response created and returned by the RPC listeners.

Summary

Methods
Properties
Constants
__construct()
import_properties()
set_type()
get_type()
get_routing_key()
get_function()
get_caller()
get_request()
get_params()
set_status()
add_response()
set_exception()
add_event_queue()
get_status()
get_called()
get_response()
get_exception()
get_event_queue()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$type
$routing_key
$function
$caller
$request
$params
$status
$called
$response
$exception
$event_queue
N/A

Properties

$type

$type :

Type

$routing_key

$routing_key :

Type

$function

$function :

Type

$caller

$caller :

Type

$request

$request :

Type

$params

$params :

Type

$status

$status :

Type

$called

$called :

Type

$response

$response :

Type

$exception

$exception :

Type

$event_queue

$event_queue :

Type

Methods

__construct()

__construct(\apex\app\interfaces\msg\EventMessageInterface  $msg)

Constructor. Get the EventMessageInterface, and set necessary properties.

Parameters

\apex\app\interfaces\msg\EventMessageInterface $msg

The message that was dispatched.

import_properties()

import_properties(\apex\app\msg\objects\event_message  $msg)

Import properties. Used by event_response object to initialize.

Parameters

\apex\app\msg\objects\event_message $msg

The message that we're creaitng a response for.

set_type()

set_type(string  $type)

Set the message type.

Parameters

string $type

Must be either 'rpc' or 'direct'.

get_type()

get_type(): string

Get the message type.

Returns

string —

The message type

get_routing_key()

get_routing_key(boolean  $return_full = false): string

Get the routing key

Parameters

boolean $return_full

If true, will return the routing key with function name. Defaults to false.

Returns

string —

$routing_key The routing key

get_function()

get_function(): string

et the function name.

Returns

string —

The function name to call.

get_caller()

get_caller(): array

Get the caller array.

Returns

array —

The caller function / class.

get_request()

get_request(): array

Get the contents of the request.

Returns

array —

Various information on the request such as URI, area, IP address, etc.

get_params()

get_params(): array

Get the params of the request.

Returns

array —

The params of the request.

set_status()

set_status(string  $status)

Set the status

Parameters

string $status

The overall status of the response. Must be either 'ok', 'fail', or 'error'

add_response()

add_response(string  $package,string  $class_name,string  $method,  $response)

Add a response

One RPC call can call methods without mltiple packages. This method is called after the RPC call is executed against any package, and adds the response from the package into the overall response object.

Parameters

string $package

The package the response came from

string $class_name

The class name that was executed

string $method

The method name that was executed

$response

set_exception()

set_exception(\apex\app\msg\objects\Exception  $e)

Set an exception

When an error occurs, this method is triggered which sets the status of the response to 'error' and includes the exception within.

Parameters

\apex\app\msg\objects\Exception $e

The exaction to add

add_event_queue()

add_event_queue()

Set the event queue

Simply calls the app::get_event_queue() method to retrieve any actions that occured during process that may change the output of the request. This is passed back to the caller for processing.

get_status()

get_status(): string

Get status of the response

Returns

string —

The status of the response

get_called()

get_called(): array

Get all classes and methods called during execution.

Returns

array —

All classes and methods called.

get_response()

get_response(string  $package = ''): mixed

Get contents of the response, either a specific package, or all packages combined in an array.

Parameters

string $package

Optional package alias to return response of. If blank, returns array of all responses from all packages.

Returns

mixed —

Either response from a specific package if defined, or all responses.

get_exception()

get_exception(): \apex\app\msg\objects\exception

get the exception, only applicable if status is 'error'.

Returns

\apex\app\msg\objects\exception —

The exception object

get_event_queue()

get_event_queue(): array

Get the event queue

Returns

array —

The event queue