class SimulatorsAdminController extends BaseAdminController

The SimulatorsAdminController class is the controller that handles all actions of the simulator management interface.

These actions are:

  • Creation of a simulator
  • Modification of a simulator
  • Import / Export of a simulator
  • Publication of a simulator
  • Deletion of a simulator

Constants

SQL_SELECT_KEYWORD

SQL_FROM_KEYWORD

SQL_WHERE_KEYWORD

SQL_ORDER_BY_KEYWORD

SQL_LIMIT_KEYWORD

Properties

ControllersHelper $helper from BaseAdminController
string $databasesDir from BaseAdminController
string $simulatorsDir from BaseAdminController
string $publicDir from BaseAdminController
string $viewsDir from BaseAdminController
Simulator $simu
private array $dataset
private array $actions
private array $rules
private array $steps
array $uricache

Methods

Response
errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

zip(array $contents)

Zip file creation function.

int
unix2DosTime(int $unixtime)

Converts unix time to MS DOS time

RedirectResponse|Response
indexAction(Request $request, string|null $simulator = null, string|null $crud = null)

Entry point for the route paths begining by /admin/simulators

RedirectResponse|Response
runIndex(Request $request, string $simulator, string $crud)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

Response
validateAction(Request $request)

Entry point for the route path : /admin/validate

Response
runValidation(Request $request)

Validates the xml file of the simulator, whose name appears in the 'xml' field of the form passed by the query, against the XML schema

RedirectResponse
doCreate(string $simulator, array $form)

Creates a simulator with the data in the form fields.

void
update(mixed $simulator, mixed $form)

Updates the simulator whose name is in the $simulator parameter with the data in the form fields.

void
doDelete(string $simulator)

Deletes a simulator whose name is in the $simulator parameter

makeSource(array $source)

Creates a Source object from an associative array of source attributes

makeParameter(array $parameter, Source $sourceObj)

Creates a Parameter object for a Source from an associative array of parameter attributes

makeDataGroup(array $datagroup)

Creates a DataGroup object from an associative array of datagroup attributes

makeData(array $data)

Creates a Data object from an associative array of data attributes

makeStep(array $step)

Creates a Step object from an associative array of step attributes

makePanel(array $panel, Step $stepObj)

Creates a Panel object for a Step from an associative array of panel attributes

makeFieldSet(array $fieldset, Panel $panelObj)

Creates a FieldSet object for a Panel from an associative array of fieldset attributes

makeFieldRow(array $fieldrow, FieldSet $fieldsetObj)

Creates a FieldRow object for a FieldSet from an associative array of fieldrow attributes

makeField(array $field, FieldSet $fieldsetObj)

Creates a Field object for a FieldSet from an associative array of field attributes

makeBlockInfo(array $blockinfo, Panel $panelObj)

Creates a BlockInfo object for a Panel from an array associative of blockinfo attributes

makeChapter(array $chapter, BlockInfo $blockinfoObj)

Creates a Chapter object for a BlockInfo from an associative array of chapter attributes

makeSection(array $section, Chapter $chapterObj)

Creates a Section object for a Chapter from an associative array of section attributes

makeBusinessRule(array $brule)

Creates a BusinessRule object from an associative array of business rule attributes

makeRuleAction(int $id, array $action)

Creates a RuleAction object from an associative array of action attributes

makeProfiles(array $profiles)

Creates a Profiles object from an associative array of profiles attributes

makeProfile(array $profile)

Creates a Profile object from an associative array of profile attributes

makeAction(array $action, Step $stepObj)

Creates an Action button object for a Step from an associative array of action attributes

string
composeSimpleSQLRequest(array $source)

Composes a simple SQL request from the supplied elements in the source associative array

loadConnector(array $connector, Connector $parentConnector = null)

Creates a Connector or a Condition object from an associative array of attributes

Response
doExportSimulator(string $simu)

Exports a simulator

RedirectResponse|StreamedResponse
doPublishSimulator(string $simu)

Publishes a simulator ie copies the xml file of the simulator from the work directory to the main directory of simulators

Response
doDeploySimulator(Request $request, string $simu)

Deploys a simulator on front-end servers

Response|RedirectResponse
doImportSimulator(array $files)

Imports a simulator by copying the uploaded definition xml file into the main simulator directory as well as the css file into the css directory of the default view if this file is uploaded by the user.

string
makeCond(array $val)

Constructs a condition in a string from an associative array containing the name, operator and value of the condition.

string
conjonct(array $conds)

Converts an array of conditions connected with the connector 'all' to a string expression in conjunctive form

string
disjonct(array $conds)

Converts an array of conditions connected with the connector 'any' to a string expression in disjunctive form

string
infix(array $conds)

Converts a boolean expression from an array to an infixed string

void
loadBusinessRules()

Load business rules

array
loadBusinessRuleField(Field $field)

makes an array of attributes of the field from the field object

array
ruleConnector(Connector|Condition $pconnector)

Builds a connector data array for the Javascript rule engine

array
actionsData(int $ruleID, array $actions)

Builds an actions data array for the Javascript rule engine

string
paragraphs(string $text)

Transforms the lines of a text into html paragraphs

string|null
findDataNameById(int $id)

Searches for the name of a data in the dataset from its identifier

Details

in BaseAdminController at line 93
protected Response errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

Parameters

array $form The form fields
string $error The error message

Return Value

Response

in BaseAdminController at line 113
protected zip(array $contents)

Zip file creation function.

Makes zip files. Derivated from PhpMyAdmin package The $contents parameter is an array of associative array where keys are : - name: name of the zip - modtime: modification time - data: data to compress

Parameters

array $contents The array of contents to be compressed

See also

Official ZIP file format: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

in BaseAdminController at line 188
protected int unix2DosTime(int $unixtime)

Converts unix time to MS DOS time

Parameters

int $unixtime (default: 0) The unix time

Return Value

int The MS DOS time

at line 180
RedirectResponse|Response indexAction(Request $request, string|null $simulator = null, string|null $crud = null)

Entry point for the route paths begining by /admin/simulators

These route paths are :

  • /admin/simulators
  • /admin/simulators/{simulator}
  • /admin/simulators/{simulator}/{crud}

Parameters

Request $request The request
string|null $simulator (default: null) simulator name
string|null $crud (default: null) operation to execute on the simulator (create, save, import, doimport, export, publish)

Return Value

RedirectResponse|Response

at line 199
protected RedirectResponse|Response runIndex(Request $request, string $simulator, string $crud)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

If the crud parameter contains no value, shows the simulator management interface.

Parameters

Request $request The request
string $simulator simulator name
string $crud (default: null) operation to execute on the simulator (create, save, import, doimport, export, publish)

Return Value

RedirectResponse|Response

at line 444
Response validateAction(Request $request)

Entry point for the route path : /admin/validate

Validates the xml file of the simulator against the XML schema.

Parameters

Request $request The request

Return Value

Response

at line 457
protected Response runValidation(Request $request)

Validates the xml file of the simulator, whose name appears in the 'xml' field of the form passed by the query, against the XML schema

Parameters

Request $request The request

Return Value

Response

at line 504
protected RedirectResponse doCreate(string $simulator, array $form)

Creates a simulator with the data in the form fields.

Route path : /admin/simulators/{simulator}/save

$form['create'] isset

Parameters

string $simulator simulator name
array $form The form fields

Return Value

RedirectResponse

at line 524
protected void update(mixed $simulator, mixed $form)

Updates the simulator whose name is in the $simulator parameter with the data in the form fields.

Route path : /admin/simulators/{simulator}/save

$form['update'] isset

Parameters

mixed $simulator simulator name
mixed $form The form fields

Return Value

void

at line 607
protected void doDelete(string $simulator)

Deletes a simulator whose name is in the $simulator parameter

Route path : /admin/simulators/{simulator}/save

$form['delete'] isset

Parameters

string $simulator simulator name

Return Value

void

at line 625
protected Source makeSource(array $source)

Creates a Source object from an associative array of source attributes

Parameters

array $source array of attributes

Return Value

Source the Source object

at line 664
protected Parameter makeParameter(array $parameter, Source $sourceObj)

Creates a Parameter object for a Source from an associative array of parameter attributes

Parameters

array $parameter array of attributes
Source $sourceObj the Source object

Return Value

Parameter the Parameter object

at line 686
protected DataGroup makeDataGroup(array $datagroup)

Creates a DataGroup object from an associative array of datagroup attributes

Parameters

array $datagroup array of attributes

Return Value

DataGroup the DataGroup object

at line 704
protected Data makeData(array $data)

Creates a Data object from an associative array of data attributes

Parameters

array $data array of attributes

Return Value

Data the Data object

at line 762
protected Step makeStep(array $step)

Creates a Step object from an associative array of step attributes

Parameters

array $step array of attributes

Return Value

Step the Step object

at line 800
protected Panel makePanel(array $panel, Step $stepObj)

Creates a Panel object for a Step from an associative array of panel attributes

Parameters

array $panel array of attributes
Step $stepObj the Step object

Return Value

Panel the Panel object

at line 823
protected FieldSet makeFieldSet(array $fieldset, Panel $panelObj)

Creates a FieldSet object for a Panel from an associative array of fieldset attributes

Parameters

array $fieldset array of attributes
Panel $panelObj the Panel object

Return Value

FieldSet the FieldSet object

at line 863
protected FieldRow makeFieldRow(array $fieldrow, FieldSet $fieldsetObj)

Creates a FieldRow object for a FieldSet from an associative array of fieldrow attributes

Parameters

array $fieldrow array of attributes
FieldSet $fieldsetObj the FieldSet object

Return Value

FieldRow the FieldRow object

at line 884
protected Field makeField(array $field, FieldSet $fieldsetObj)

Creates a Field object for a FieldSet from an associative array of field attributes

Parameters

array $field array of attributes
FieldSet $fieldsetObj the FieldSet object

Return Value

Field the Field object

at line 922
protected BlockInfo makeBlockInfo(array $blockinfo, Panel $panelObj)

Creates a BlockInfo object for a Panel from an array associative of blockinfo attributes

Parameters

array $blockinfo array of attributes
Panel $panelObj the Panel object

Return Value

BlockInfo the BlockInfo object

at line 941
protected Chapter makeChapter(array $chapter, BlockInfo $blockinfoObj)

Creates a Chapter object for a BlockInfo from an associative array of chapter attributes

Parameters

array $chapter array of attributes
BlockInfo $blockinfoObj the BlockInfo object

Return Value

Chapter the Chapter object

at line 962
protected Section makeSection(array $section, Chapter $chapterObj)

Creates a Section object for a Chapter from an associative array of section attributes

Parameters

array $section array of attributes
Chapter $chapterObj the Chapter object

Return Value

Section the Section object

at line 981
protected BusinessRule makeBusinessRule(array $brule)

Creates a BusinessRule object from an associative array of business rule attributes

Parameters

array $brule array of attributes

Return Value

BusinessRule the BusinessRule object

at line 1010
protected RuleAction makeRuleAction(int $id, array $action)

Creates a RuleAction object from an associative array of action attributes

Parameters

int $id id of the latest rule action
array $action array of attributes

Return Value

RuleAction the RuleAction object

at line 1151
protected Profiles makeProfiles(array $profiles)

Creates a Profiles object from an associative array of profiles attributes

Parameters

array $profiles array of attributes

Return Value

Profiles the Profiles object

at line 1168
protected Profile makeProfile(array $profile)

Creates a Profile object from an associative array of profile attributes

Parameters

array $profile array of attributes

Return Value

Profile the Profile object

at line 1187
protected Action makeAction(array $action, Step $stepObj)

Creates an Action button object for a Step from an associative array of action attributes

Parameters

array $action array of attributes
Step $stepObj the Step object

Return Value

Action the Action object

at line 1204
private string composeSimpleSQLRequest(array $source)

Composes a simple SQL request from the supplied elements in the source associative array

Parameters

array $source

Return Value

string the SQL request string

at line 1257
private Connector|Condition loadConnector(array $connector, Connector $parentConnector = null)

Creates a Connector or a Condition object from an associative array of attributes

If the array contains the key 'all', 'any' or 'none' then a Connector object is returned else a Condition object is returned.

Parameters

array $connector array of attributes
Connector $parentConnector (default: null) Parent connector

Return Value

Connector|Condition

at line 1288
protected Response doExportSimulator(string $simu)

Exports a simulator

Route path : /admin/simulators/{simulator}/export

Creates a compressed file containing the XML definition and the stylesheet of the simulator for downloading by the user. The XML file is the working version if it exists otherwise it is the published version.

Parameters

string $simu simulator name

Return Value

Response

at line 1332
protected RedirectResponse|StreamedResponse doPublishSimulator(string $simu)

Publishes a simulator ie copies the xml file of the simulator from the work directory to the main directory of simulators

Route path : /admin/simulators/{simulator}/publish

Parameters

string $simu simulator name

Return Value

RedirectResponse|StreamedResponse

at line 1384
protected Response doDeploySimulator(Request $request, string $simu)

Deploys a simulator on front-end servers

Route path : /admin/simulators/{simulator}/deploy

Parameters

Request $request
string $simu The name of the simulator to deploy

Return Value

Response

at line 1425
protected Response|RedirectResponse doImportSimulator(array $files)

Imports a simulator by copying the uploaded definition xml file into the main simulator directory as well as the css file into the css directory of the default view if this file is uploaded by the user.

Before copying, the file is validated against the xml schema and if there is an error, a Response object is generated with the error message returned by the validator.

If a css file is not provided and it does not already exist in the view directory, a css file is created by importing common.css from the 'Demo' view.

Route path : /admin/simulators/{simulator}/doimport

Parameters

array $files Uploaded files

Return Value

Response|RedirectResponse a Response object if there is an error, a RedirectResponse otherwise.

at line 1520
private string makeCond(array $val)

Constructs a condition in a string from an associative array containing the name, operator and value of the condition.

Parameters

array $val Name, operator and value of the condition

Return Value

string The condition

at line 1562
private string conjonct(array $conds)

Converts an array of conditions connected with the connector 'all' to a string expression in conjunctive form

Parameters

array $conds The array of conditions

Return Value

string The string expression in conjunctive form

at line 1594
private string disjonct(array $conds)

Converts an array of conditions connected with the connector 'any' to a string expression in disjunctive form

Parameters

array $conds The array of conditions

Return Value

string The string expression in disjunctive form

at line 1662
private string infix(array $conds)

Converts a boolean expression from an array to an infixed string

Conversion example:

$conds = array(
    'any' => array(
        array(
            'all' => array(
                array(
                    'name' => 'income',
                    'operator' => '>=',
                    'value' => 2000
                 ),
                 array(
                    'name' => 'rate',
                    'operator' => '>',
                    'value' => 15.5
                 )
            )
        ),
        array(
            'name' => 'nChildren',
            'operator' => '<',
            'value' => 5
        )
    )
);

is converted to:

"(#1 >= 2000 && #2 > 15.5) || #3 < 5"

where :

  • #1 is the id of the data whose name is 'income' prefixed by #
  • #2 is the id of the data whose name is 'rate' prefixed by #
  • #3 is the id of the data whose name is 'nChildren' prefixed by #

Parameters

array $conds The array of boolean expression

Return Value

string The infixed expression

at line 1687
protected void loadBusinessRules()

Load business rules

Return Value

void

at line 3153
protected array loadBusinessRuleField(Field $field)

makes an array of attributes of the field from the field object

Parameters

Field $field The field object

Return Value

array Array of attributes of the field

at line 3183
private array ruleConnector(Connector|Condition $pconnector)

Builds a connector data array for the Javascript rule engine

Parameters

Connector|Condition $pconnector

Return Value

array The connector data array

at line 3211
private array actionsData(int $ruleID, array $actions)

Builds an actions data array for the Javascript rule engine

Parameters

int $ruleID rule ID
array $actions array of RuleAction objects

Return Value

array The actions data array

at line 3498
private string paragraphs(string $text)

Transforms the lines of a text into html paragraphs

Parameters

string $text

Return Value

string

at line 3518
private string|null findDataNameById(int $id)

Searches for the name of a data in the dataset from its identifier

Parameters

int $id data id

Return Value

string|null data name