OctetStream
extends File
in package
Class OctetStream
Outputs the results as an octet-stream.
Table of Contents
- $id : mixed
- Processor ID.
- $status : mixed
- The HTTP output status.
- $data : DataContainer
- The output data.
- $details : array<string|int, mixed>
- An array of details of the processor, used to configure the frontend GUI and metadata construction.
- $header : string
- Content-type header value.
- $logger : MonologWrapper
- Logger object.
- $meta : array<string|int, mixed>
- Metadata for the processor.
- $request : Request
- All the request details.
- __construct() : mixed
- details() : array<string|int, mixed>
- Return details for processor.
- detectType() : string
- Detect the type of data that is input .
- fromArrayToFile() : bool
- Convert array to file.
- fromBooleanToFile() : bool
- Convert boolean to file.
- fromFileToFile() : bool
- Convert file to file.
- fromFloatToFile() : bool
- Convert float to file.
- fromHtmlToFile() : bool
- Convert HTML to file.
- fromImageToFile() : bool
- Convert image to file.
- fromIntegerToFile() : bool
- Convert integer to file.
- fromJsonToFile() : bool
- Convert JSON to file.
- fromTextToFile() : bool
- Convert text to file.
- fromUndefinedToFile() : null
- Convert undefined to file.
- fromXmlToFile() : bool
- Convert XML to file.
- isArray() : bool
- Validate a variable is an array.
- isBool() : bool
- Validate a variable is boolean.
- isEmpty() : bool
- Validate a variable is empty.
- isFloat() : bool
- Validate a variable is float.
- isHtml() : bool
- Validate a variable is HTML.
- isInt() : bool
- Validate a variable is integer.
- isJson() : bool
- Validate a variable is JSON.
- isXml() : bool
- Validate a variable is XML.
- process() : mixed
- Main processor function.
- setHeader() : void
- Set the response headers.
- setResponseCode() : void
- Set the HTML response code.
- val() : mixed|DataContainer
- Process a variable into a final result for the processor.
- castData() : mixed
- Cast the data to the required Type.
- isDataContainer() : bool
- Validate if a set of data is wrapped in a DataContainer object.
- validateAllowedTypes() : void
- Validate an input for allowed variable types
- validateAllowedValues() : void
- Validate an input for allowed values.
Properties
$id
Processor ID.
public
mixed
$id
= ''
Processor ID.
$status
The HTTP output status.
public
mixed
$status
The output status.
$data
The output data.
protected
DataContainer
$data
The output data.
$details
An array of details of the processor, used to configure the frontend GUI and metadata construction.
protected
array<string|int, mixed>
$details
= array()
Details of the processor.
Indexes: 'name' (string): Human readable name of the processor.
'machineName' (string): Machine name of the processor in snake case.
'description' (string): Description of the processor.
'menu' (string): Lists the immediate menu parents.
examples: 'menu' => 'menu1' - belongs to menu1
'conditional' (optional, boolean):
ApiOpenStudio usually parses the node tree using depth-first iteration. In some cases, this may be wasteful because a processor may require conditional branching, in which case, we do not want to parse all comparison values until we know what branch we will take, i.e. in if_then_else processor, we do not need to process both the 'then' and the 'else' branches.
If omitted or set to false: The parsing will continue as normal (depth-first).
If set to true: The processor will be calculated and then the result branch will be returned and added to the stack.
'input': List the input nodes for this processor This is an array with the following indexes:
'description' (string): description of what the processor does
'cardinality': (int min, mixed max) e.g. [0, 1] max can be integer or ''. '' = infinite
'literalAllowed' (boolean): Allow liter values.
'limitValues' (array|mixed): Limit the result values passed into the processor.
'limitProcessors' (array|string): Limit the input processors.
'limitTypes' (array): an array of input type this processor will accept. Possible values: file literal bool numeric integer text float bool
'conditional' (optional): In the case of branching processors (see 'preprocess' above), this indicates if the input is a conditional input or required for the logic comparison.
examples: input => [ 'sources' => [ 'description' => 'desc1', 'cardinality' => [1, '*'], type => ['literal'] ] ] This processor has only one input, called sources. Sources must contain at least one value. The inputs can only be a literal value.
input => [
'method' => [
'description' => 'desc1',
'cardinality' => [1, 1],
'literalAllowed': true
'limitType': ['text'],
'limitValues' => ["get", "post"]
],
'auth' => [
'description' => 'desc2',
'cardinality' => [1, 1],
'limitProcessors' => ['var_get'],
],
'vars' => [
'description' => 'desc3',
'cardinality' => [0, '*'],
limitTypes => ['integer'],
],
't' => [
'description' => 'desc4',
'cardinality' => [0, '*'],
'limitProcessors' => ['field'],
],
]
This Processor has 4 inputs:
method, which has only one input, of type text, with only 2 possible values ('get' and 'post'),
literals are allowed.
auth, which has only one value, of type processor (var_get).
vars, which can contain:
0 or many values
Must be an integer
with no limit on value
t, which can take or many input of Processor Field.
$header
Content-type header value.
protected
string
$header
= ''
The string to contain the content type header value.
$logger
Logger object.
protected
MonologWrapper
$logger
$meta
Metadata for the processor.
protected
array<string|int, mixed>
$meta
$request
All the request details.
protected
Request
$request
Request.
Methods
__construct()
public
__construct(array<string|int, mixed> &$meta, Request &$request[, MonologWrapper|null $logger = null ]) : mixed
Parameters
- $meta : array<string|int, mixed>
-
Metadata for the processor.
- $request : Request
-
The full request object.
- $logger : MonologWrapper|null = null
-
The logger.
Return values
mixed —details()
Return details for processor.
public
details() : array<string|int, mixed>
Return values
array<string|int, mixed> —detectType()
Detect the type of data that is input .
public
detectType(mixed $data) : string
Parameters
- $data : mixed
-
Data to test.
Return values
string —The data type.
fromArrayToFile()
Convert array to file.
public
fromArrayToFile( $data) : bool
Parameters
Tags
Return values
bool —fromBooleanToFile()
Convert boolean to file.
public
fromBooleanToFile( $data) : bool
Parameters
Return values
bool —fromFileToFile()
Convert file to file.
public
fromFileToFile( $data) : bool
Parameters
Return values
bool —fromFloatToFile()
Convert float to file.
public
fromFloatToFile( $data) : bool
Parameters
Return values
bool —fromHtmlToFile()
Convert HTML to file.
public
fromHtmlToFile( $data) : bool
Parameters
Return values
bool —fromImageToFile()
Convert image to file.
public
fromImageToFile( $data) : bool
Parameters
Return values
bool —fromIntegerToFile()
Convert integer to file.
public
fromIntegerToFile( $data) : bool
Parameters
Return values
bool —fromJsonToFile()
Convert JSON to file.
public
fromJsonToFile( $data) : bool
Parameters
Return values
bool —fromTextToFile()
Convert text to file.
public
fromTextToFile( $data) : bool
Parameters
Return values
bool —fromUndefinedToFile()
Convert undefined to file.
public
fromUndefinedToFile( $data) : null
Parameters
Return values
null —fromXmlToFile()
Convert XML to file.
public
fromXmlToFile( $data) : bool
Parameters
Return values
bool —isArray()
Validate a variable is an array.
public
isArray(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isBool()
Validate a variable is boolean.
public
isBool(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isEmpty()
Validate a variable is empty.
public
isEmpty(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isFloat()
Validate a variable is float.
public
isFloat(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isHtml()
Validate a variable is HTML.
public
isHtml(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isInt()
Validate a variable is integer.
public
isInt(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isJson()
Validate a variable is JSON.
public
isJson(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —isXml()
Validate a variable is XML.
public
isXml(mixed $var) : bool
Parameters
- $var : mixed
-
Variable to test.
Return values
bool —process()
Main processor function.
public
process() : mixed
This is where the magic happens, and should be overridden by all derived classes.
Fetches and process the processor described in the metadata. It is also the 1st stop to recursive processing of processors, so the place validate user credentials.
Tags
Return values
mixed —setHeader()
Set the response headers.
public
setHeader() : void
Return values
void —setResponseCode()
Set the HTML response code.
public
setResponseCode() : void
Return values
void —val()
Process a variable into a final result for the processor.
public
val(string $key[, bool|null $rawData = false ]) : mixed|DataContainer
This method can be used to process a value in its meta to return a final result that it can use. If the object is a processor, then it will process that down to a final return value, or if the obj is a simple value, then it will return that. Anything else will return an error object.
Setting $realValue to true will force the value to be the actual value, rather than a potential dataContainer.
Parameters
- $key : string
-
The key for the input variable in the meta.
- $rawData : bool|null = false
-
Return the raw data or a DataContainer.
Tags
Return values
mixed|DataContainer —castData()
Cast the data to the required Type.
protected
abstract castData() : mixed
Tags
Return values
mixed —isDataContainer()
Validate if a set of data is wrapped in a DataContainer object.
protected
isDataContainer(mixed $data) : bool
Parameters
- $data : mixed
-
DataContainer or raw data.
Return values
bool —validateAllowedTypes()
Validate an input for allowed variable types
private
validateAllowedTypes(string $type, array<string|int, mixed> $limitTypes, int $min, string $key) : void
Parameters
- $type : string
-
Input value type.
- $limitTypes : array<string|int, mixed>
-
List of limit on variable types.
- $min : int
-
Minimum number of values.
- $key : string
-
The key of the input being validated.
Tags
Return values
void —validateAllowedValues()
Validate an input for allowed values.
private
validateAllowedValues(mixed $val, array<string|int, mixed> $limitValues, int $min, string $key) : void
Parameters
- $val : mixed
-
Input value.
- $limitValues : array<string|int, mixed>
-
List of allowed values.
- $min : int
-
Minimum number of values.
- $key : string
-
The key of the input being validated.