ApiOpenStudio PHPDoc

ProcessorEntity extends Entity
in package

Class ProcessorEntity

Base class for all entities.

Table of Contents

$db  : ADOConnection
DB connections.
$details  : array<string|int, mixed>
An array of details of the processor, used to configure the frontend GUI and metadata construction.
$id  : int
Processor ID.
$logger  : MonologWrapper
Logger object.
$meta  : mixed
Meta required for this processor.
$request  : Request
All the request details.
__construct()  : mixed
Constructor. Store processor metadata and request data in object.
details()  : array<string|int, mixed>
Return details for processor.
process()  : mixed
Main processor function.
val()  : mixed|DataContainer
Process a variable into a final result for the processor.
generateParams()  : array<string|int, mixed>
Generate the params array for the sql search.
getUserAccids()  : array<string|int, mixed>
Get the accids for accounts that the user has roles for.
getUserAppids()  : DataContainer
Get the appids for applications that the user has roles for.
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

$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: Human readable name of the processor.

machineName: Machine name of the processor.

description: Description of the processor.

menu: Lists the immediate menu parents.

examples: 'menu' => 'menu1' - belongs to menu1

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 sult 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

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.

$meta

Meta required for this processor.

protected mixed $meta

Processor metadata.

Methods

__construct()

Constructor. Store processor metadata and request data in object.

public __construct( $meta, Request &$request[, ADOConnection|null $db = null ][, MonologWrapper|null $logger = null ]) : mixed
Parameters
$meta :

Metadata for the processor.

$request : Request

The full request object.

$db : ADOConnection|null = null

The DB connection 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>

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
throws
ApiException
Return values
mixed

val()

Process a variable into a final result for the processor.

public val(string $key[, bool|null $realValue = null ]) : mixed|DataContainer

This method can be used to process a value in it's 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.

$realValue : bool|null = null

Return the real value or a dataContainer.

Tags
throws
ApiException

Invalid key or data.

Return values
mixed|DataContainer

generateParams()

Generate the params array for the sql search.

protected generateParams(string $keyword, array<string|int, mixed> $keywordCols, string $orderBy, string $direction) : array<string|int, mixed>
Parameters
$keyword : string

Search keyword.

$keywordCols : array<string|int, mixed>

Columns to search for the keyword.

$orderBy : string

Order by column.

$direction : string

Order direction.

Return values
array<string|int, mixed>

getUserAccids()

Get the accids for accounts that the user has roles for.

protected getUserAccids(int $uid) : array<string|int, mixed>
Parameters
$uid : int

User ID.

Tags
throws
ApiException
Return values
array<string|int, mixed>

getUserAppids()

Get the appids for applications that the user has roles for.

protected getUserAppids(int $uid) : DataContainer
Parameters
$uid : int

User ID.

Tags
throws
ApiException

Exception flowing though.

Return values
DataContainer

Array of appid.

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 valiable types.

$min : int

Minimum number of values.

$key : string

The key of the input being validated.

Tags
throws
ApiException

Invalid data type.

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.

Tags
throws
ApiException

Invalid value.

Return values
void

Search results