Documentation

Controller
in package

Controller Handler Class

This abstract class serves as a base for processing web requests. Inherit from it and create functions that can be called, for example:

Tags
example

class PageController extends Colibri\Web\Controller {

    public function Method1($get, $post, $payload) {

        Write what is needed here and finish the function with the Finish method.

        Attention:
        Modifying $get, $post, $payload is meaningless, as they are copies of the data passed in the request.

        PROHIBITED:
        1. Output anything using echo, print_r, var_dump, etc.
        2. Requesting other RPC Handlers at the same level.
        3. Implementing business logic in the handler class (inheritors of RpcHandler).

        $code = 200 | 400, etc.
        $message = any message
        $result = response payload, can be a string in the case of html/xml

        ! NO ECHO ALLOWED !!!!

        Example of result:

        div => [
            span => test
        ]

        XML helper will create:

        <div><span>test</span></div>

        HTML helper will create:

        <div class="div"><div class="span">test</div></div>

        return $this->Finish(int $code, string $message, mixed $result);

    }

}

Table of Contents

Properties

$_cache  : bool
$_lifetime  : int
$_type  : string|null

Methods

__construct()  : mixed
Constructor.
__get()  : mixed
Magic getter method.
Finish()  : object
Finish handler execution.
GetEntryPoint()  : string
Generate a URL for entry point addition.
Invoke()  : mixed
Invokes the specified method and handles caching if enabled.

Properties

Methods

__construct()

Constructor.

public __construct([string|null $type = null ]) : mixed
Parameters
$type : string|null = null

The type of response (e.g., json, xml, html).

__get()

Magic getter method.

public __get(string $prop) : mixed
Parameters
$prop : string

The property name.

Return values
mixed

The value of the property.

Finish()

Finish handler execution.

public Finish(int $code, string $message[, mixed $result = null ][, string $charset = 'utf-8' ][, array<string|int, mixed> $headers = [] ][, array<string|int, mixed> $cookies = [] ][, bool $forceNoCache = false ]) : object
Parameters
$code : int

The error code.

$message : string

The message.

$result : mixed = null

Additional parameters.

$charset : string = 'utf-8'

The character encoding.

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

Additional headers.

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

Cookies to be set.

$forceNoCache : bool = false

Whether to force no caching.

Return values
object

The finished result.

GetEntryPoint()

Generate a URL for entry point addition.

public static GetEntryPoint([string $method = '' ][, string $type = '' ][, array<string|int, mixed> $params = [] ]) : string
Parameters
$method : string = ''

The name of the function in the controller class.

$type : string = ''

The type of return value: json, xml, html.

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

GET parameters.

Return values
string

The generated URL.


        
On this page

Search results