51Degrees Pipeline for PHP

fiftyone\pipeline\core\JavascriptBuilderElement Class Reference

Detailed Description

The JavaScriptBuilder aggregates JavaScript properties from FlowElements in the Pipeline.

This JavaScript also (when needed) generates a fetch request to retrieve additional properties populated with data from the client side It depends on the JSON Bundler element (both are automatically added to a Pipeline unless specifically removed) for its list of properties. The results of the JSON Bundler should also be used in a user-specified endpoint which retrieves the JSON from the client side. The JavaScriptBuilder is constructed with a url for this endpoint.

Inheritance diagram for fiftyone\pipeline\core\JavascriptBuilderElement:

[legend]

Collaboration diagram for fiftyone\pipeline\core\JavascriptBuilderElement:

[legend]

Public Member Functions

 __construct (array $settings=[])
 getEvidenceKeyFilter ()
 The JavaScriptBuilder captures query string evidence and headers for detecting whether the request is http or https.
 processInternal (FlowData $flowData)
 The JavaScriptBundler collects client side javascript to serve.

Public Member Functions inherited from fiftyone\pipeline\core\FlowElement

 __construct ()
 A default dummy constructor is needed for there are classes inheriting this class deeper than 1-level of inheritance and calling parent::__construct() in their explicit constructors.
 process (FlowData $flowData)
 General wrapper function that calls a FlowElement's processInternal method.
 filterEvidence (FlowData $flowData)
 Filter FlowData evidence using the FlowElement's EvidenceKeyFilter.
 filterEvidenceKey (string $key)
 Filter FlowData evidence using the FlowElement's EvidenceKeyFilter.
 onRegistration (Pipeline $pipeline)
 Callback called when an engine is added to a pipeline.
 getProperties ()
 Get properties Usually overridden by specific FlowElements.
 updatePropertyList ()
 Update a FlowElement's property list This is used by elements that are only aware of their properties at a later stage, such as cloud request based FlowElements or FlowElements that change their properties later based on new datafiles.

Static Public Member Functions

static isValidObjectName ($name)
 Whether a name can be used as the client side object's name.
static parseSequence ($value)
 A sequence as a positive 32 bit integer, or null when the value cannot be used as one.
static getSequence ($value)
 The sequence to render into the script.
static getSessionId ($value)
 The session id to render into the script.

Data Fields

const MAX_SEQUENCE = 2147483647
 The largest sequence, which is the largest 32 bit signed integer.
array $settings
bool $minify
string $dataKey = 'javascriptbuilder'

Data Fields inherited from fiftyone\pipeline\core\FlowElement

string $dataKey
array $properties = []
array $pipelines = []

Constructor & Destructor Documentation

◆ __construct()

fiftyone\pipeline\core\JavascriptBuilderElement::__construct ( array $settings = [])
Parameters
array<string,mixed>$settings 'objName' is the name of the client side object, 'fod' when absent or null. The page request can ask for a different name with the 'query.fod-js-object-name' evidence. A name must be a JavaScript identifier (ASCII letters, digits, '_' and '$', not starting with a digit) and not a reserved word. An invalid 'objName', the empty string included, throws an \InvalidArgumentException, and an invalid requested name is ignored with a warning logged.

Member Function Documentation

◆ getEvidenceKeyFilter()

fiftyone\pipeline\core\JavascriptBuilderElement::getEvidenceKeyFilter ( )

The JavaScriptBuilder captures query string evidence and headers for detecting whether the request is http or https.

Reimplemented from fiftyone\pipeline\core\FlowElement.

◆ getSequence()

fiftyone\pipeline\core\JavascriptBuilderElement::getSequence ( $value)
static

The sequence to render into the script.

The template writes the sequence as bare code (var sequence = ...;), so anything other than a whole number would stop the script parsing, or change what it does. A pipeline without a SequenceElement passes the query string's value, or nothing at all, straight through, and the pipeline specification requires 1 in that case. This builder goes a little further than the specification currently says and renders 1 for any value that is not a positive 32 bit integer, because the script counts its own requests up from this number and cannot use zero or a negative one.

Parameters
mixed$valueThe query.sequence evidence, or null

◆ getSessionId()

fiftyone\pipeline\core\JavascriptBuilderElement::getSessionId ( $value)
static

The session id to render into the script.

The template writes the session id inside quotes without any escaping, so a session id that is not 1 to 64 ASCII letters, digits and hyphens is rendered as an empty string, whether it came from the SequenceElement or from the query string, as the pipeline specification says.

Parameters
mixed$valueThe query.session-id evidence, or null

◆ isValidObjectName()

fiftyone\pipeline\core\JavascriptBuilderElement::isValidObjectName ( $name)
static

Whether a name can be used as the client side object's name.

The name is written into the script as a variable name, a session storage key and a property name, all without any escaping, so a name that is not a plain JavaScript identifier would break the script or change what it does.

Parameters
mixed$name

◆ parseSequence()

fiftyone\pipeline\core\JavascriptBuilderElement::parseSequence ( $value)
static

A sequence as a positive 32 bit integer, or null when the value cannot be used as one.

Parameters
mixed$valueThe query.sequence evidence, or null

◆ processInternal()

fiftyone\pipeline\core\JavascriptBuilderElement::processInternal ( FlowData $flowData)

The JavaScriptBundler collects client side javascript to serve.

Reimplemented from fiftyone\pipeline\core\FlowElement.