SimulatorsAdminController
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
Returns a JSON response formed with the data of a form and an error message.
Entry point for the route paths begining by /admin/simulators
Dispatches the index action to the appropriate processing based on the value of the crud parameter.
Entry point for the route path : /admin/validate
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
Creates a simulator with the data in the form fields.
Updates the simulator whose name is in the $simulator parameter with the data in the form fields.
Deletes a simulator whose name is in the $simulator parameter
Creates a Source object from an associative array of source attributes
Creates a Parameter object for a Source from an associative array of parameter attributes
Creates a DataGroup object from an associative array of datagroup attributes
Creates a FieldSet object for a Panel from an associative array of fieldset attributes
Creates a FieldRow object for a FieldSet from an associative array of fieldrow attributes
Creates a BlockInfo object for a Panel from an array associative of blockinfo attributes
Creates a Chapter object for a BlockInfo from an associative array of chapter attributes
Creates a Section object for a Chapter from an associative array of section attributes
Creates a BusinessRule object from an associative array of business rule attributes
Creates a RuleAction object from an associative array of action attributes
Creates a Profiles object from an associative array of profiles attributes
Creates a Profile object from an associative array of profile attributes
Creates an Action button object for a Step from an associative array of action attributes
Composes a simple SQL request from the supplied elements in the source associative array
Creates a Connector or a Condition object from an associative array of attributes
Exports a simulator
Publishes a simulator ie copies the xml file of the simulator from the work directory to the main directory of simulators
Deploys a simulator on front-end servers
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.
Constructs a condition in a string from an associative array containing the name, operator and value of the condition.
Converts an array of conditions connected with the connector 'all' to a string expression in conjunctive form
Converts an array of conditions connected with the connector 'any' to a string expression in disjunctive form
Converts a boolean expression from an array to an infixed string
Load business rules
Builds a connector data array for the Javascript rule engine
Builds an actions data array for the Javascript rule engine
Transforms the lines of a text into html paragraphs
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.
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
in BaseAdminController at line 188
protected int
unix2DosTime(int $unixtime)
Converts unix time to 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}
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.
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.
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
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
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
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
at line 625
protected Source
makeSource(array $source)
Creates a Source object from an associative array of source attributes
at line 664
protected Parameter
makeParameter(array $parameter, Source $sourceObj)
Creates a Parameter object for a Source from an associative array of parameter attributes
at line 686
protected DataGroup
makeDataGroup(array $datagroup)
Creates a DataGroup object from an associative array of datagroup attributes
at line 704
protected Data
makeData(array $data)
Creates a Data object from an associative array of data attributes
at line 762
protected Step
makeStep(array $step)
Creates a Step object from an associative array of step attributes
at line 800
protected Panel
makePanel(array $panel, Step $stepObj)
Creates a Panel object for a Step from an associative array of panel attributes
at line 823
protected FieldSet
makeFieldSet(array $fieldset, Panel $panelObj)
Creates a FieldSet object for a Panel from an associative array of fieldset attributes
at line 863
protected FieldRow
makeFieldRow(array $fieldrow, FieldSet $fieldsetObj)
Creates a FieldRow object for a FieldSet from an associative array of fieldrow attributes
at line 884
protected Field
makeField(array $field, FieldSet $fieldsetObj)
Creates a Field object for a FieldSet from an associative array of field attributes
at line 922
protected BlockInfo
makeBlockInfo(array $blockinfo, Panel $panelObj)
Creates a BlockInfo object for a Panel from an array associative of blockinfo attributes
at line 941
protected Chapter
makeChapter(array $chapter, BlockInfo $blockinfoObj)
Creates a Chapter object for a BlockInfo from an associative array of chapter attributes
at line 962
protected Section
makeSection(array $section, Chapter $chapterObj)
Creates a Section object for a Chapter from an associative array of section attributes
at line 981
protected BusinessRule
makeBusinessRule(array $brule)
Creates a BusinessRule object from an associative array of business rule attributes
at line 1010
protected RuleAction
makeRuleAction(int $id, array $action)
Creates a RuleAction object from an associative array of action attributes
at line 1151
protected Profiles
makeProfiles(array $profiles)
Creates a Profiles object from an associative array of profiles attributes
at line 1168
protected Profile
makeProfile(array $profile)
Creates a Profile object from an associative array of profile attributes
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
at line 1204
private string
composeSimpleSQLRequest(array $source)
Composes a simple SQL request from the supplied elements in the source associative array
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.
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.
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
at line 1384
protected Response
doDeploySimulator(Request $request, string $simu)
Deploys a simulator on front-end servers
Route path : /admin/simulators/{simulator}/deploy
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
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.
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
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
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 #
at line 1687
protected void
loadBusinessRules()
Load business rules
at line 3153
protected array
loadBusinessRuleField(Field $field)
makes an array of attributes of the field from the field object
at line 3183
private array
ruleConnector(Connector|Condition $pconnector)
Builds a connector data array for the Javascript rule engine
at line 3211
private array
actionsData(int $ruleID, array $actions)
Builds an actions data array for the Javascript rule engine
at line 3498
private string
paragraphs(string $text)
Transforms the lines of a text into html paragraphs
at line 3518
private string|null
findDataNameById(int $id)
Searches for the name of a data in the dataset from its identifier