Español Español English English Français
The WebAbility® Network

The WebAbility®
Network

Enter the Web Effect

Documentación WebAbility® Network [Página principal]
The engine flow super box: ( /Box/reference/Engine )

I. Box flow


A box flow is a definition of a number of boxes that are linked together with those rules:
- A flow is lineal, means there cannot be loops between the boxes
- A box output can only be linked with another box input.
- Linked inputs and ouputs must be compatibles in type of data (see table below).
- Unlinked inputs must be filled before running the flow.

You may use a same box many times in the same flow, however, every time you use the box, a new instance will be created.

II. Definition of a flow


2.1. XML definition


The XML have 2 blocks nested into the 'enginebox' tag:
'boxes': is the list of boxes we are going to use into the flow, with links to other boxes,
'outputs': is the list of outputs.
The id of the tag is the name of our flow.

The engine sets automatically all the needed inputs based on the flow definition, i.e. all the not linked inputs of the flow definition.


<?xml version="1.0" encoding="UTF-8" ?>
<enginebox id="product">
<boxes>
</boxes>

<outputs>
</outputs>

</enginebox>



Each tag in the boxes is the name of the box, and contains the definition of this box.

Format:


<nameofbox>
<box>class of the box</box>
<inputs>
<nameofinput><from>origin</from><data>nameofparameter</data></nameifinput>
...
</inputs>
</nameofbox>



The origin can be:
inline: the data contains the value to pass to the box
inputs: the data contains the name of the value to pass to the box
caller: the data contains the method of the caller to call to get the value
function: the data contains the function to call to get the value
integrator: the data contains a new array of inputs. All the inputs will be passed as an array to the box
[name of another box]: the data contains the id of the output of this box

Example:


<producttemplate>
<box>templateBox</box>
<inputs>
<elements>
<from>integrator</from>
<data>
<__MATRIX__><from>productmatrix</from><data>template</data></__MATRIX__>
<__PAGINATION__><from>productpages</from><data>template</data></__PAGINATION__>
<__PAGECATALOG__><from>inline</from><data>seecatalog.php</data></__PAGECATALOG__>
<__PAGEPRODUCT__><from>inline</from><data>seeproduct.php</data></__PAGEPRODUCT__>
<__PAGECART__><from>function</from><data>getPageCart</data></__PAGECART__>
<__VARMAXPERPAGE__><from>inputs</from><data>VARMAXPERPAGE</data></__VARMAXPERPAGE__>
<__VARCATEGORY__><from>inputs</from><data>VARCATEGORY</data></__VARCATEGORY__>
<__CATEGORY__><from>inputs</from><data>CATEGORY</data></__CATEGORY__>
<__VARPRODUCT__><from>inputs</from><data>VARPRODUCT</data></__VARPRODUCT__>
</data>
</elements>
<language><from>inputs</from><data>languages/producttemplate.language</data></language>
<template><from>inputs</from><data>templates/producttemplate.template</data></template>
</inputs>
</producttemplate>



The outputs are a list of outputs of each boxes.


<outputs>
<result><from>boxid</from><data>outputid</data></result>
</outputs>



The boxid is the id of the box contained into the definition of boxes in the first block.
The outputid is the id of the output of this box.


2.2. Array definition




III. Using the engine


If you are going to use only one engine box into your code, you only need to create an instance with the flow definition, assign the inputs then run the flow.

Standalone code:


// create an engine
$flowdef = '/path/to/flow.xml';
$e = new engineBox($flowdef);

// assign all the inputs of your flow
$e->setInputData('id', 'value');

// run the flow
$e->run();

// get the outputs
$o = $e->getOutputData('id');



Engine encapsulated into an Object:


class flowrunner
{
function X()
{
// create an engine
$flowdef = '/path/to/flow.xml';
$e = new engineBox($flowdef, $this);

// assign all the inputs of your flow
$e->setInputData('id', 'value');

// run the flow
$e->run();

// get the outputs
$o = $e->getOutputData('id');

return $o;
}

function getParams($id)
{
// Some params into your flow call this method to get the value of any parameter
return "params value";
}

}



If you are going to use your engineBox into another flow, you should entend the engine to set the flow definition:


class myFlowBox extends engineBox
{
function __construct()
{
parent::__construct('path/to/your/flow.xml');
}
}

$macroengine = new engine('another/flow.xml');

...




The $macroengine flow will use myFlowBox as a simple box somewhere into the definition of all the boxes.


[Ver la página] [Modificar] [Archivos multimedia] [Bitácora de cambios] [Seguridad] [Borrar esta página] [Cambiar el ID] [Herramientas]












WebAbility®, © 2000-2012 Philippe Thomassigny - Algunos derechos reservados