SwooleRequest
extends Request
in package
Define common HTTP request object
Table of Contents
- $method : string|null
- The http request method
- $args : array<string|int, mixed>|null
- The interface arguments from url
- $body : Result|null
- The parsed request body
- $domain : Domain|null
- the system domain
- $file : mixed|string
- The file name
- $folder : string
- The absolute folder path
- $git_repo : Git|null
- The repository instance
- $handler : ServerPlugin|null
- Custom handler
- $has_init : bool
- $inbound : string|null
- The buffer for the inbound payload
- $is_api : bool
- Flag is some sort of api call
- $is_directory : bool
- Flag is most likely a directory call
- $language : string|null
- The request language, either from first segment or,from optimizer table
- $languages : array<string|int, mixed>
- The local active language buffer
- $original_path : string
- the original url
- $parsed : array<string|int, mixed>|null
- $path : array<string|int, mixed>
- The absolute path split from request
- $plain_path : string
- the plain path
- $query : array<string|int, mixed>
- List of query parameters
- $relation : string|null
- The private relation Is set in case of detail content relation requests
- $sh : SessionHandler|null
- $sr : Request|null
- $user : User|null
- $user_groups : array<string|int, mixed>|null
- Storage for user groups
- __construct() : mixed
- Simple main constructor, parses the request and specifies the targeted type
- Cached() : bool
- Get no cache context
- ChangeTransaction() : void
- ContextType() : string
- The context type
- Cookie() : string|null
- Get cookie value
- CurrentDomain() : Domain|null
- Get the current domain object.
- Get() : mixed
- GetAcceptLanguageList() : array<string|int, string>
- Get accept language list expose a reference to the external given language list
- GetBody() : Result|string
- get request body content this method provides reading access payload of the request
- GetFile() : string
- get local requested file component of url expose a reference to the current file
- GetFolder() : string
- Get local requested folder component of url
- GetInterfaceArg() : array<string|int, mixed>|int|string
- Get part of the request url
- GetInterfaceArgs() : array<string|int, mixed>|string
- get REST end point components this method rebuilds the original call and provides the components as array
- GetLanguage() : string|null
- Get request language
- GetLanguageList() : array<string|int, string>
- get language list expose a reference to the current loaded language list
- GetPath() : string
- get REST end point plain this method provides reading access to the REST url
- GetQuery() : array<string|int, mixed>|string|null
- Get query Get the query or a part of the query
- GetRelation() : string|null
- Get the relation id
- GetUser() : User|null
- Get current user
- GetUserGroups() : array<string|int, mixed>|null
- Get user groups
- HasCustomHandler() : bool
- Has custom handler
- Header() : mixed|null
- Get header from request
- Hostname() : string|null
- Expose the host of this request
- Id() : string
- Generate request id
- InboundData() : string|null
- Get inbound data
- IsXhr() : bool
- Is the non really standardized xhr indicator present?
- LogLine() : bool
- Log line write a line to the local system logfile
- Origin() : string
- Get origin Return the value of the set origin header
- OriginalPath() : string
- Expose the original request url
- Protocol() : string
- We assume that it is https anyway
- Referer() : string|null
- Get the referer
- RegisterCustomHandler() : void
- Register a system plugin or a child of with ServeRequest method
- RemoteAddress() : string|null
- Get the remote address
- Repository() : Git
- Get the git instance
- RequestMethod() : string
- Get method Get the buffered http request method string e.g. POST, GET, PUT
- ServeRequest() : void
- Serve custom request
- SessionHandler() : SessionHandler
- Set() : mixed
- SystemTime() : float
- Time() : int|float
- The request time
- TrimInterfaceArgs() : array<string|int, mixed>
- Remove parts of the request path based on given length
- UploadFiles() : array<string|int, mixed>|null
- Get list of uploaded files
- Uri() : string|null
- The request uri without get
- getTranslation() : string
- detectDomain() : mixed
- Detect current domain
- fixHomePath() : string
- Correct the request path set a redirect header to the given location
- lazy() : mixed
- loadLanguages() : mixed
- load languages
- read() : string|null
- Read the input body
- readInboundStream() : string|null
- Raw read body load the post body into a string
Properties
$method
The http request method
protected
string|null
$method
= null
$args
The interface arguments from url
private
array<string|int, mixed>|null
$args
= null
Is filled in case of rest interface call
$body
The parsed request body
private
Result|null
$body
= null
$domain
the system domain
private
Domain|null
$domain
= null
$file
The file name
private
mixed|string
$file
= ''
$folder
The absolute folder path
private
string
$folder
= ''
Is defined for content requests
$git_repo
The repository instance
private
Git|null
$git_repo
= null
$handler
Custom handler
private
ServerPlugin|null
$handler
= null
A handler serving the request and returning a defined response object. May be set in plugin context
$has_init
private
bool
$has_init
= false
$inbound
The buffer for the inbound payload
private
string|null
$inbound
= null
$is_api
Flag is some sort of api call
private
bool
$is_api
= false
$is_directory
Flag is most likely a directory call
private
bool
$is_directory
= false
$language
The request language, either from first segment or,from optimizer table
private
string|null
$language
= null
$languages
The local active language buffer
private
array<string|int, mixed>
$languages
= array()
$original_path
the original url
private
string
$original_path
= ''
$parsed
private
array<string|int, mixed>|null
$parsed
$path
The absolute path split from request
private
array<string|int, mixed>
$path
= array()
$plain_path
the plain path
private
string
$plain_path
= ''
$query
List of query parameters
private
array<string|int, mixed>
$query
= array()
$relation
The private relation Is set in case of detail content relation requests
private
string|null
$relation
= null
$sh
private
SessionHandler|null
$sh
$sr
private
Request|null
$sr
$user
private
User|null
$user
= null
$user_groups
Storage for user groups
private
array<string|int, mixed>|null
$user_groups
= null
Methods
__construct()
Simple main constructor, parses the request and specifies the targeted type
public
__construct(Request $sr, SessionHandler $sh) : mixed
Parameters
- $sr : Request
- $sh : SessionHandler
Return values
mixed —Cached()
Get no cache context
public
Cached() : bool
Tags
Return values
bool —ChangeTransaction()
public
ChangeTransaction(BaseContent $content, string &$path, bool $read) : void
Parameters
- $content : BaseContent
- $path : string
- $read : bool
Return values
void —ContextType()
The context type
public
ContextType() : string
Return values
string —Cookie()
Get cookie value
public
Cookie(string $name) : string|null
Parameters
- $name : string
Return values
string|null —CurrentDomain()
Get the current domain object.
public
CurrentDomain() : Domain|null
Return values
Domain|null —A domain object
Get()
public
Get(string $sg, string|null $key[, mixed $default = null ]) : mixed
Parameters
- $sg : string
- $key : string|null
- $default : mixed = null
Return values
mixed —GetAcceptLanguageList()
Get accept language list expose a reference to the external given language list
public
GetAcceptLanguageList() : array<string|int, string>
Return values
array<string|int, string> —the local request language list
GetBody()
get request body content this method provides reading access payload of the request
public
GetBody([bool $parsed = true ][, string|null $charset = null ]) : Result|string
Parameters
- $parsed : bool = true
-
When set to true, return as parsed json payload
- $charset : string|null = null
Return values
Result|string —The payload as string or a system result object
GetFile()
get local requested file component of url expose a reference to the current file
public
GetFile() : string
Return values
string —the local request file
GetFolder()
Get local requested folder component of url
public
GetFolder([bool $clear = false ]) : string
Expose a reference to the current folder, can clear the folder name so it can be used as an id
Parameters
- $clear : bool = false
-
Clear path on demand
Return values
string —The local request folder
GetInterfaceArg()
Get part of the request url
public
GetInterfaceArg( $index[, $format = FAA_REQUEST_ARG_FORMAT_NONE ]) : array<string|int, mixed>|int|string
Parameters
Return values
array<string|int, mixed>|int|string —The interface argument parsed
GetInterfaceArgs()
get REST end point components this method rebuilds the original call and provides the components as array
public
GetInterfaceArgs([bool|int $index = false ]) : array<string|int, mixed>|string
Parameters
- $index : bool|int = false
-
When set > 1 function will return the element at offset
Return values
array<string|int, mixed>|string —The end point as array or a single component
GetLanguage()
Get request language
public
GetLanguage([string $format = '' ]) : string|null
Expose a reference to the current language
Parameters
- $format : string = ''
-
If set to iso, the code will be extended to e.g. de_DE
Return values
string|null —The local request language
GetLanguageList()
get language list expose a reference to the current loaded language list
public
GetLanguageList() : array<string|int, string>
Return values
array<string|int, string> —the local request language list
GetPath()
get REST end point plain this method provides reading access to the REST url
public
GetPath([bool $decode = false ]) : string
Parameters
- $decode : bool = false
Return values
string —the end point as string
GetQuery()
Get query Get the query or a part of the query
public
GetQuery([string|null $item = null ][, mixed $default = null ]) : array<string|int, mixed>|string|null
Parameters
- $item : string|null = null
-
A certain item
- $default : mixed = null
Return values
array<string|int, mixed>|string|null —GetRelation()
Get the relation id
public
GetRelation() : string|null
expose a reference to the current loaded relation
Return values
string|null —The local request relation id or null
GetUser()
Get current user
public
GetUser() : User|null
Tags
Return values
User|null —GetUserGroups()
Get user groups
public
GetUserGroups() : array<string|int, mixed>|null
Get the user groups of the requesting user. Will contain the visitor group for users without session.
Return values
array<string|int, mixed>|null —List of user group id's and visitor group
HasCustomHandler()
Has custom handler
public
HasCustomHandler() : bool
Check if a custom handler is registered for this request Could be the case if a plugin will serve the request
Return values
bool —Has handler
Header()
Get header from request
public
Header(string $string) : mixed|null
Parameters
- $string : string
Return values
mixed|null —Hostname()
Expose the host of this request
public
Hostname([bool $name_only = true ]) : string|null
Parameters
- $name_only : bool = true
Return values
string|null —Id()
Generate request id
public
Id() : string
A unique request identifier based on folder, language and requester groups. Can be used in caching relations when permission and folder is relevant. E.g. in navigation renderer.
Return values
string —the 32 character request id
InboundData()
Get inbound data
public
InboundData() : string|null
Return values
string|null —IsXhr()
Is the non really standardized xhr indicator present?
public
IsXhr() : bool
Return values
bool —LogLine()
Log line write a line to the local system logfile
public
LogLine(mixed $value[, string $level = FAA_LOG_LEVEL_INFO ]) : bool
Parameters
- $value : mixed
-
The log message or any kind of object
- $level : string = FAA_LOG_LEVEL_INFO
-
The log level
Tags
Return values
bool —Write success or false on error
Origin()
Get origin Return the value of the set origin header
public
Origin() : string
Return values
string —The value of the origin header
OriginalPath()
Expose the original request url
public
OriginalPath([bool $decode = false ]) : string
Parameters
- $decode : bool = false
Return values
string —Protocol()
We assume that it is https anyway
public
Protocol() : string
Return values
string —Referer()
Get the referer
public
Referer() : string|null
Return values
string|null —RegisterCustomHandler()
Register a system plugin or a child of with ServeRequest method
public
RegisterCustomHandler(ServerPlugin $handler) : void
Parameters
- $handler : ServerPlugin
-
A system plugin
Return values
void —RemoteAddress()
Get the remote address
public
RemoteAddress() : string|null
Return values
string|null —Repository()
Get the git instance
public
Repository() : Git
Return values
Git —RequestMethod()
Get method Get the buffered http request method string e.g. POST, GET, PUT
public
RequestMethod() : string
Return values
string —The request method
ServeRequest()
Serve custom request
public
ServeRequest(Response $response) : void
Serve the request using the registered custom handler
Parameters
- $response : Response
Return values
void —SessionHandler()
public
SessionHandler() : SessionHandler
Return values
SessionHandler —Set()
public
Set(string $sg, string $key, mixed $data) : mixed
Parameters
- $sg : string
- $key : string
- $data : mixed
Return values
mixed —SystemTime()
public
SystemTime() : float
Return values
float —Time()
The request time
public
Time([bool $float = false ]) : int|float
Parameters
- $float : bool = false
Return values
int|float —TrimInterfaceArgs()
Remove parts of the request path based on given length
public
TrimInterfaceArgs( $length) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —UploadFiles()
Get list of uploaded files
public
UploadFiles([string|null $param_name = null ]) : array<string|int, mixed>|null
Parameters
- $param_name : string|null = null
Return values
array<string|int, mixed>|null —Uri()
The request uri without get
public
Uri() : string|null
Return values
string|null —getTranslation()
protected
getTranslation(string $data, string $l[, string $type = 'code' ][, string $src = '' ]) : string
Parameters
- $data : string
- $l : string
- $type : string = 'code'
- $src : string = ''
Return values
string —detectDomain()
Detect current domain
private
detectDomain() : mixed
Load the system domains to a local structure this method is mostly used for caching purpose and matching domains by key
Return values
mixed —fixHomePath()
Correct the request path set a redirect header to the given location
private
fixHomePath() : string
Return values
string —lazy()
private
lazy() : mixed
Return values
mixed —loadLanguages()
load languages
private
loadLanguages() : mixed
load the system languages to a local structure this method is mostly used for caching purpose and matching locales by key
Return values
mixed —read()
Read the input body
private
read() : string|null
Return values
string|null —readInboundStream()
Raw read body load the post body into a string
private
readInboundStream() : string|null
Return values
string|null —the parsed body as string