Documentation

Server extends Server
in package

Web server

Table of Contents

Constants

CSS  = 'css'
HTML  = 'html'
IncorrectCommandObject  = 1
List of errors
JS  = 'js'
JSON  = 'json'
List of types
NotRpcQuery  = 'This is not a Rpc query'
Stream  = 'stream'
UnknownMethodInObject  = 2
XML  = 'xml'

Methods

__construct()  : mixed
Constructor
DispatchEvent()  : object|null
Dispatches an event.
HandleEvent()  : self
Adds an event handler.
RemoveHandler()  : self
Removes an event handler.
Run()  : void
Runs the specified command.
_getControllerFullName()  : string
Gets the full controller class name with namespace.
_responseWithError()  : void
Sends an error response in XML format.
Finish()  : void
Finishes the process and sends response.
__parseCommand()  : array<string|int, mixed>
Parses command URL to determine type, class, and method.
_convertDataToCharset()  : mixed
Converts data to specified charset recursively.

Constants

IncorrectCommandObject

List of errors

public mixed IncorrectCommandObject = 1

JSON

List of types

public mixed JSON = 'json'

NotRpcQuery

public mixed NotRpcQuery = 'This is not a Rpc query'

Stream

public mixed Stream = 'stream'

UnknownMethodInObject

public mixed UnknownMethodInObject = 2

Methods

__construct()

Constructor

public __construct() : mixed

DispatchEvent()

Dispatches an event.

public DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
$event : string|Event

The event object or its name.

$args : mixed = null

Additional arguments to pass to the event handlers.

$async : bool = false

Whether to dispatch the event asynchronously.

Return values
object|null

The event object with updated arguments, or null if the event does not exist.

HandleEvent()

Adds an event handler.

public HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
$ename : array<string|int, mixed>|string

The event name or an array of event names.

$listener : mixed

The event handler.

Return values
self

RemoveHandler()

Removes an event handler.

public RemoveHandler(string $ename, mixed $listener) : self
Parameters
$ename : string

The event name.

$listener : mixed

The event handler to remove.

Return values
self

Run()

Runs the specified command.

public Run(string $cmd[, string $default = '' ]) : void

The command should be in the following format: /namespace[/namespace]/command[.type]

Parameters
$cmd : string

The command to execute.

$default : string = ''

The default command to execute if the specified command is not found.

_getControllerFullName()

Gets the full controller class name with namespace.

protected _getControllerFullName(string $class) : string
Parameters
$class : string

The class name.

Return values
string

The full class name.

_responseWithError()

Sends an error response in XML format.

protected _responseWithError(string $type, string $message[, int $code = -1 ][, string $cmd = '' ][, mixed $data = null ]) : void
Parameters
$type : string

The response type.

$message : string

The error message.

$code : int = -1

The error code.

$cmd : string = ''

The command.

$data : mixed = null

Additional data.

Finish()

Finishes the process and sends response.

protected Finish(string $type, mixed $result) : void
Parameters
$type : string

The response type.

$result : mixed

The result to send.

__parseCommand()

Parses command URL to determine type, class, and method.

private __parseCommand(string $cmd) : array<string|int, mixed>
Parameters
$cmd : string

The command URL.

Return values
array<string|int, mixed>

An array containing type, class, and method.

_convertDataToCharset()

Converts data to specified charset recursively.

private _convertDataToCharset(mixed $data, string $charset) : mixed
Parameters
$data : mixed

The data to convert.

$charset : string

The charset to convert to.

Return values
mixed

The converted data.


        
On this page

Search results