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
Traits
Constants
SQL_SELECT_KEYWORD |
|
SQL_FROM_KEYWORD |
|
SQL_WHERE_KEYWORD |
|
SQL_ORDER_BY_KEYWORD |
|
SQL_LIMIT_KEYWORD |
|
Properties
protected mixed | $projectDir | from BaseAdminController | |
protected mixed | $translator | from BaseAdminController | |
protected mixed | $kernel | from BaseAdminController | |
protected mixed | $userManager | from BaseAdminController | |
protected mixed | $authorizationChecker | from BaseAdminController | |
protected mixed | $fileUploader | from BaseAdminController | |
protected mixed | $deployer | from BaseAdminController | |
string | $databasesDir | from BaseAdminController | |
string | $simulatorsDir | from BaseAdminController | |
string | $publicDir | from BaseAdminController | |
string | $viewsDir | from BaseAdminController | |
Simulator|null | $simu | ||
private array | $dataset | ||
private array | $actions | ||
private array | $rules | ||
private array | $steps | ||
array | $uricache |
Methods
Constructor of class BaseAdminController
Returns a JSON response formed with the data of a form and an error message.
Returns the browser engine from the user agent
Populates the list of values of a data item of type choice from a data source.
Populates the list of values of a data item of type choice from a data source where columns are in the given ChoiceSource object.
Returns the formatted value of the data item where the ID is in the first element of the given array.
Replaces all data ID by their corresponding value into the given text.
Prefix with a # and returns the prefixed ID of the data item where the ID is in the first element of the given array.
Replaces all the html tag data containing the ID of a data item by # followed by the ID
Composes a footnote reference string [text^ID(title)] with the elements of the given array.
Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]
Replaces all the html tag dfn and data with their text equivalent
Returns the list of available widgets by type (g6k type).
Returns the list of available widgets by form input type.
Retrieves the Data object of a data item of the current simulator by its ID.
Retrieves an action node by its name in the actions tree from the supplied node
Retrieves an action field node in the given fields list for the given current option node
Retrieves an action field option node by its value in the field list of the given action node
Makes a date string from an array [year, month, day], according to the date format.
Return a relative path to a file or directory using base directory.
Run a console command.
Run a streamed console command.
Determines whether the symfony kernel is in development mode or not.
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/regional-settings/{locale}
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
Renames a simulator
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
Makes the header for an action report
Makes the footer for an action report
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 an actions data array for the Javascript rule engine
Finds the disposition of a fieldset where one of the elements is the target of a rule action
Makes a clause from the fields of a rule cation
Searches for the name of a data in the dataset from its identifier
Returns the available locales of the server
Returns the languages for the current locale
Returns the time zones for the given locale
Returns all the currency symbols
Returns the regional settings for the given locale
Details
in BaseAdminController at line 150
void
__construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, UserManagerInterface $userManager, FileUploader $fileUploader, Deployer $deployer, mixed $projectDir)
Constructor of class BaseAdminController
in BaseAdminController at line 169
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 189
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 264
protected int
unix2DosTime(int $unixtime = 0)
Converts unix time to MS DOS time
in ControllersTrait at line 66
protected void
initialize()
Initialization of common directories
in ControllersTrait at line 81
KernelInterface
getKernel()
Returns the Symfony kernel
in ControllersTrait at line 92
TranslatorInterface
getTranslator()
Returns the translator interface
in ControllersTrait at line 103
bool
hasParameter($parameters)
Checks if a parameter exists or not
in ControllersTrait at line 119
string
getLocale()
Returns the 'locale' from config parameters
in ControllersTrait at line 130
string
getLanguage()
Returns the 'app_language' from config parameters
in ControllersTrait at line 142
protected string
getBrowserEngine(Request $request)
Returns the browser engine from the user agent
in ControllersTrait at line 187
protected string|null
formatParamValue(Parameter $param)
Formats a source parameter value
in ControllersTrait at line 247
protected DataSource
getDatasource(Source $source)
Returns the data source accessed by a source query
in ControllersTrait at line 265
mixed
processSource(Source $source)
Process a source query and returns the result of that query.
in ControllersTrait at line 442
void
populateChoiceWithSource(Data $data)
Populates the list of values of a data item of type choice from a data source.
in ControllersTrait at line 466
protected void
populateChoice(Data $data, ChoiceSource $choiceSource)
Populates the list of values of a data item of type choice from a data source where columns are in the given ChoiceSource object.
in ControllersTrait at line 505
protected string
replaceVariable(array $matches)
Returns the formatted value of the data item where the ID is in the first element of the given array.
If the second element of the given array is 'L' and if the data item is a choice, the label is returned instead of the value.
in ControllersTrait at line 559
RichText|string
replaceVariables(RichText|string $target)
Replaces all data ID by their corresponding value into the given text.
in ControllersTrait at line 587
protected string
replaceDataTag(array $matches)
Prefix with a # and returns the prefixed ID of the data item where the ID is in the first element of the given array.
in ControllersTrait at line 604
RichText|string
replaceDataTagByVariable(RichText|string $target)
Replaces all the html tag data containing the ID of a data item by # followed by the ID
in ControllersTrait at line 627
protected string
replaceDfnTag(array $matches)
Composes a footnote reference string [text^ID(title)] with the elements of the given array.
in ControllersTrait at line 643
RichText|string
replaceDfnTagByFootnote(RichText|string $target)
Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]
in ControllersTrait at line 666
string
replaceSpecialTags(string $target)
Replaces all the html tag dfn and data with their text equivalent
in ControllersTrait at line 679
array
getWidgets()
Returns the list of available widgets.
in ControllersTrait at line 696
array
getWidgetsByType()
Returns the list of available widgets by type (g6k type).
in ControllersTrait at line 726
array
getWidgetsByInputType()
Returns the list of available widgets by form input type.
in ControllersTrait at line 756
array
getFunctions()
Returns the label of available functions.
in ControllersTrait at line 783
Data|null
getDataById(int $id)
Retrieves the Data object of a data item of the current simulator by its ID.
in ControllersTrait at line 796
array|null
findAction(string $name, array $fromNode)
Retrieves an action node by its name in the actions tree from the supplied node
in ControllersTrait at line 814
array|null
findActionField(array $fields, array $currentNode)
Retrieves an action field node in the given fields list for the given current option node
in ControllersTrait at line 837
array|null
findActionOption(string $name, string $value, array $node)
Retrieves an action field option node by its value in the field list of the given action node
in ControllersTrait at line 860
protected string|null
makeDateString(array $dateArray)
Makes a date string from an array [year, month, day], according to the date format.
in ControllersTrait at line 898
private String
getRelativePath(String $base, String $path)
Return a relative path to a file or directory using base directory.
in ControllersTrait at line 916
private bool
runConsoleCommand(array $command, array|null $report = null)
Run a console command.
in ControllersTrait at line 954
private StreamedResponse
runStreamedConsoleCommand(array $command, callable $start, callable $end)
Run a streamed console command.
in ControllersTrait at line 980
bool
isDevelopmentEnvironment()
Determines whether the symfony kernel is in development mode or not.
in ControllersTrait at line 991
string
getEnvironment()
Returns the current environment
at line 177
RedirectResponse|Response
index(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 196
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 485
Response
regionalSettings(Request $request, string $locale)
Entry point for the route path /admin/regional-settings/{locale}
at line 505
Response
validate(Request $request)
Entry point for the route path : /admin/validate
Validates the xml file of the simulator against the XML schema.
at line 518
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 564
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 584
protected void
update(string $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 690
protected void
doDelete(string $simulator)
Deletes a simulator whose name is in the $simulator parameter
Route path : /admin/simulators/{simulator}/delete
at line 719
protected void
doRename(string $oldName, string $newName)
Renames a simulator
at line 758
protected void
doDeleteWorkingVersion(string $simulator)
Deletes a simulator whose name is in the $simulator parameter
Route path : /admin/simulators/{simulator}/delete-working-version
or /admin/simulators/{simulator}/save and $form['delete'] isset
at line 776
protected Source
makeSource(array $source)
Creates a Source object from an associative array of source attributes
at line 815
protected Parameter
makeParameter(array $parameter, Source $sourceObj)
Creates a Parameter object for a Source from an associative array of parameter attributes
at line 837
protected DataGroup
makeDataGroup(array $datagroup)
Creates a DataGroup object from an associative array of datagroup attributes
at line 860
protected Data
makeData(array $data)
Creates a Data object from an associative array of data attributes
at line 926
protected Step
makeStep(array $step)
Creates a Step object from an associative array of step attributes
at line 975
protected Panel
makePanel(array $panel, Step $stepObj)
Creates a Panel object for a Step from an associative array of panel attributes
at line 998
protected FieldSet
makeFieldSet(array $fieldset, Panel $panelObj)
Creates a FieldSet object for a Panel from an associative array of fieldset attributes
at line 1043
protected FieldRow
makeFieldRow(array $fieldrow, FieldSet $fieldsetObj)
Creates a FieldRow object for a FieldSet from an associative array of fieldrow attributes
at line 1064
protected Field
makeField(array $field, FieldSet $fieldsetObj)
Creates a Field object for a FieldSet from an associative array of field attributes
at line 1112
protected BlockInfo
makeBlockInfo(array $blockinfo, Panel $panelObj)
Creates a BlockInfo object for a Panel from an array associative of blockinfo attributes
at line 1137
protected Chapter
makeChapter(array $chapter, BlockInfo $blockinfoObj)
Creates a Chapter object for a BlockInfo from an associative array of chapter attributes
at line 1158
protected Section
makeSection(array $section, Chapter $chapterObj)
Creates a Section object for a Chapter from an associative array of section attributes
at line 1187
protected BusinessRule
makeBusinessRule(array $brule)
Creates a BusinessRule object from an associative array of business rule attributes
at line 1216
protected RuleAction
makeRuleAction(int $id, array $action)
Creates a RuleAction object from an associative array of action attributes
at line 1369
protected Profiles
makeProfiles(array $profiles)
Creates a Profiles object from an associative array of profiles attributes
at line 1386
protected Profile
makeProfile(array $profile)
Creates a Profile object from an associative array of profile attributes
at line 1410
protected Action
makeAction(array $action, Step $stepObj)
Creates an Action button object for a Step from an associative array of action attributes
at line 1429
private string
composeSimpleSQLRequest(array $source)
Composes a simple SQL request from the supplied elements in the source associative array
at line 1482
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 1513
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 1579
protected string
makeReportHeader(Request $request, string $simu, string $heading)
Makes the header for an action report
at line 1615
protected string
makeReportFooter(Request $request, string $simu)
Makes the footer for an action report
at line 1640
protected StreamedResponse
doPublishSimulator(Request $request, 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 1687
protected StreamedResponse
doDeploySimulator(Request $request, string $simu)
Deploys a simulator on front-end servers
Route path : /admin/simulators/{simulator}/deploy
at line 1729
protected StreamedResponse
doImportSimulator(Request $request)
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 1834
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 1876
private string
conjonct(array $conds)
Converts an array of conditions connected with the connector 'all' to a string expression in conjunctive form
at line 1908
private string
disjonct(array $conds)
Converts an array of conditions connected with the connector 'any' to a string expression in disjunctive form
at line 1976
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 2001
protected void
loadBusinessRules()
Load business rules
at line 3573
protected array
loadBusinessRuleField(Field $field)
makes an array of attributes of the field from the field object
at line 3604
private array
actionsData(int $ruleID, array $actions)
Builds an actions data array for the Javascript rule engine
at line 3817
private string
findDisposition(RuleAction $action)
Finds the disposition of a fieldset where one of the elements is the target of a rule action
at line 3832
private array
makeClause(array $fields)
Makes a clause from the fields of a rule cation
at line 3850
private RichText|string
paragraphs(RichText|string $string)
Transforms the lines of a text into html paragraphs
at line 3883
private string|null
findDataNameById(int $id)
Searches for the name of a data in the dataset from its identifier
at line 3899
private array
getLocales()
Returns the available locales of the server
at line 3922
array
getLanguages()
Returns the languages for the current locale
at line 3955
array
getTimezones(string $locale)
Returns the time zones for the given locale
at line 3972
array
getCurrencySymbols()
Returns all the currency symbols
at line 3992
array
getRegionalSettings(string $locale)
Returns the regional settings for the given locale