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
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
$_cache
protected
bool
$_cache
= false
$_lifetime
protected
int
$_lifetime
= 600
$_type
protected
string|null
$_type
= null
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.
Invoke()
Invokes the specified method and handles caching if enabled.
public
Invoke(string $method, RequestCollection $get, RequestCollection $post, PayloadCopy $payload) : mixed
Parameters
- $method : string
-
The method to invoke.
- $get : RequestCollection
-
The GET request collection.
- $post : RequestCollection
-
The POST request collection.
- $payload : PayloadCopy
-
The payload copy.
Return values
mixed —The result of the method invocation.