class IndexController extends BaseController

The IndexController class is the controller that give of online simulators.

Traits

This class implements common functions needed in G6KBundle controllers.
This class implements common functions needed in G6KBundle controllers.

Properties

protected mixed $projectDir from BaseController
protected mixed $translator from BaseController
protected mixed $kernel from BaseController
protected mixed $authorizationChecker from BaseController
Simulator $simu from BaseController
protected Parser $parser from BaseController
protected bool $error from BaseController
protected int $recursion from BaseController
protected array $simuWidgets from BaseController
protected array $simuFunctions from BaseController
protected array $variables from BaseController
protected array $memo from BaseController
protected mixed|null $sources from BaseController
protected array $log from BaseController
protected int $script from BaseController
protected array $sequence from BaseController
protected string $path from BaseController
array $uricache from BaseController
string $databasesDir from BaseController
string $simulatorsDir from BaseController
string $publicDir from BaseController
string $viewsDir from BaseController

Methods

void
initialize()

Initialization of common directories

KernelInterface
getKernel()

Returns the Symfony kernel

TranslatorInterface
getTranslator()

Returns the translator interface

bool
hasParameter($parameters)

Checks if a parameter exists or not

string
getLocale()

Returns the 'locale' from config parameters

string
getLanguage()

Returns the 'app_language' from config parameters

string
getBrowserEngine(Request $request)

Returns the browser engine from the user agent

string|null
formatParamValue(Parameter $param)

Formats a source parameter value

getDatasource(Source $source)

Returns the data source accessed by a source query

mixed
processSource(Source $source)

Process a source query and returns the result of that query.

void
populateChoiceWithSource(Data $data)

Populates the list of values of a data item of type choice from a data source.

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.

string
replaceVariable(array $matches)

Returns the formatted value of the data item where the ID is in the first element of the given array.

RichText|string
replaceVariables(RichText|string $target)

Replaces all data ID by their corresponding value into the given text.

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.

RichText|string
replaceDataTagByVariable(RichText|string $target)

Replaces all the html tag data containing the ID of a data item by # followed by the ID

string
replaceDfnTag(array $matches)

Composes a footnote reference string [text^ID(title)] with the elements of the given array.

RichText|string
replaceDfnTagByFootnote(RichText|string $target)

Replaces all the html tag dfn containing the ID of a footnote by [text^ID(title)]

string
replaceSpecialTags(string $target)

Replaces all the html tag dfn and data with their text equivalent

array
getWidgets()

Returns the list of available widgets.

array
getWidgetsByType()

Returns the list of available widgets by type (g6k type).

array
getWidgetsByInputType()

Returns the list of available widgets by form input type.

array
getFunctions()

Returns the label of available functions.

Data|null
getDataById(int $id)

Retrieves the Data object of a data item of the current simulator by its ID.

array|null
findAction(string $name, array $fromNode)

Retrieves an action node by its name in the actions tree from the supplied node

array|null
findActionField(array $fields, array $currentNode)

Retrieves an action field node in the given fields list for the given current option node

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

string|null
makeDateString(array $dateArray)

Makes a date string from an array [year, month, day], according to the date format.

String
getRelativePath(String $base, String $path)

Return a relative path to a file or directory using base directory.

bool
runConsoleCommand(array $command, array|null $report = null)

Run a console command.

StreamedResponse
runStreamedConsoleCommand(array $command, callable $start, callable $end)

Run a streamed console command.

bool
isDevelopmentEnvironment()

Determines whether the symfony kernel is in development mode or not.

string
getEnvironment()

Returns the current environment

void
__construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, mixed $projectDir)

Constructor of class BaseController

Response|Step|null
runStep(Request $request, array $form, string $simu, string $view, bool $test)

Run the simulation engine for a step

void
addWidget(string $widget)

Adds a widget to the list of widgets

void
widgetDeps(string $widget, array $widgets, array $availWidgets)

Adds widgets that depend on a widget in the list of widgets

void
addFunction(string $function)

Adds a function to the list of functions

void
functionDeps(string $function, array $functions, array $availFunctions)

Adds functions that depend on a function in the list of functions

Response
runFields(Request $request, string $simu, bool $test = false)

Returns the simulators attributes in JSON response format

Response
runSource(Request $request, string $simu, bool $test = false)

Returns the requested source attributes in JSON response format

string
getSimuPath(string $simu, bool $test = false)

Get the simulators directory

void
checkField(Field $field, array $form, bool $skipValidation)

Checks the given field

void
processField(Field $field, Step $step, bool $displayable)

Processes the given field for the step

void
replaceFieldNotes(Field $field)

Replaces data values in the notes of a field

string|false
evaluate(string $condition)

Evaluates a condition with the expression parser

void
evaluateDefault(Data $data)

Evaluates the default value of the given data

void
evaluateDefaults()

Evaluates the default value of all data

void
evaluateMin(Data $data)

Evaluates the minimum value of the given data

void
evaluateMax(Data $data)

Evaluates the maximum value of the given data

void
evaluateMinMax()

Evaluates the minimum and the maximum value of all data

void
processData(Data $data, int $istep)

Processes the given data for the step

void
processActions(array $actions, int $istep)

Executes all the actions of a business rule of the step

void
processRule(BusinessRule $businessrule, int $istep)

Evaluates the conditions of a business rule an executes the suitable actions

void
processRules(int $istep)

Evaluates the conditions of all business rules an executes the suitable actions

void
processDatas(int $istep)

Processes all data for the step

Response
index(Request $request)

Entry point for the route path /

Response
runIndex(Request $request)

Dispatches the index action to the appropriate processing.

Details

in ControllersTrait at line 66
protected void initialize()

Initialization of common directories

Return Value

void

in ControllersTrait at line 81
KernelInterface getKernel()

Returns the Symfony kernel

Return Value

KernelInterface $kernel The Symfony kernel

in ControllersTrait at line 92
TranslatorInterface getTranslator()

Returns the translator interface

Return Value

TranslatorInterface The translator interface

in ControllersTrait at line 103
bool hasParameter($parameters)

Checks if a parameter exists or not

Parameters

$parameters

Return Value

bool true the parameter exists, false otherwise

in ControllersTrait at line 119
string getLocale()

Returns the 'locale' from config parameters

Return Value

string The locale

in ControllersTrait at line 130
string getLanguage()

Returns the 'app_language' from config parameters

Return Value

string The app_language

in ControllersTrait at line 142
protected string getBrowserEngine(Request $request)

Returns the browser engine from the user agent

Parameters

Request $request the active request

Return Value

string The browser engine

in ControllersTrait at line 187
protected string|null formatParamValue(Parameter $param)

Formats a source parameter value

Parameters

Parameter $param The source parameter

Return Value

string|null The formatted value

in ControllersTrait at line 247
protected DataSource getDatasource(Source $source)

Returns the data source accessed by a source query

Parameters

Source $source The source

Return Value

DataSource The data source

in ControllersTrait at line 265
mixed processSource(Source $source)

Process a source query and returns the result of that query.

Parameters

Source $source The source

Return Value

mixed The result of the 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.

Parameters

Data $data &$data The data item of type choice

Return Value

void

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.

Parameters

Data $data &$data The data item of type choice
ChoiceSource $choiceSource The given ChoiceSource object

Return Value

void

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.

Parameters

array $matches The given array

Return Value

string The formatted value of the data item

in ControllersTrait at line 559
RichText|string replaceVariables(RichText|string $target)

Replaces all data ID by their corresponding value into the given text.

Parameters

RichText|string $target The target text

Return Value

RichText|string The result 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.

Parameters

array $matches The given array

Return Value

string The prefixed ID

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

Parameters

RichText|string $target The target text

Return Value

RichText|string The result text

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.

Parameters

array $matches The given array

Return Value

string The footnote reference string

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)]

Parameters

RichText|string $target The target text

Return Value

RichText|string The result text

in ControllersTrait at line 666
string replaceSpecialTags(string $target)

Replaces all the html tag dfn and data with their text equivalent

Parameters

string $target The target text

Return Value

string The result text

in ControllersTrait at line 679
array getWidgets()

Returns the list of available widgets.

Return Value

array The list of available widgets

in ControllersTrait at line 696
array getWidgetsByType()

Returns the list of available widgets by type (g6k type).

Return Value

array The list of available widgets

in ControllersTrait at line 726
array getWidgetsByInputType()

Returns the list of available widgets by form input type.

Return Value

array The list of available widgets

in ControllersTrait at line 756
array getFunctions()

Returns the label of available functions.

Return Value

array 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.

Parameters

int $id The ID of the data item.

Return Value

Data|null The Data object

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

Parameters

string $name The name of the action
array $fromNode The supplied node

Return Value

array|null The action 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

Parameters

array $fields The fields list
array $currentNode The current option node

Return Value

array|null The action field 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

Parameters

string $name The field name
string $value The option value
array $node The action node

Return Value

array|null The action field option 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.

Parameters

array $dateArray The given array

Return Value

string|null The date string

in ControllersTrait at line 898
private String getRelativePath(String $base, String $path)

Return a relative path to a file or directory using base directory.

Parameters

String $base A base path used to construct relative path. For example /website
String $path A full path to file or directory used to construct relative path. For example /website/store/library.php

Return Value

String

in ControllersTrait at line 916
private bool runConsoleCommand(array $command, array|null $report = null)

Run a console command.

Parameters

array $command The command
array|null $report &$report An array for receiving the output of the command

Return Value

bool

in ControllersTrait at line 954
private StreamedResponse runStreamedConsoleCommand(array $command, callable $start, callable $end)

Run a streamed console command.

Parameters

array $command The command
callable $start a callback function to be called at the begining of the stream
callable $end a callback function to be called at the end of the stream

Return Value

StreamedResponse

in ControllersTrait at line 980
bool isDevelopmentEnvironment()

Determines whether the symfony kernel is in development mode or not.

Return Value

bool true if the symfony kernel is in development mode, false otherwise

in ControllersTrait at line 991
string getEnvironment()

Returns the current environment

Return Value

string The first letters of the current environment

in BaseController at line 105
void __construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, mixed $projectDir)

Constructor of class BaseController

Parameters

TranslatorInterface $translator
KernelInterface $kernel
AuthorizationCheckerInterface $authorizationChecker
mixed $projectDir

Return Value

void

in BaseController at line 270
protected Response|Step|null runStep(Request $request, array $form, string $simu, string $view, bool $test)

Run the simulation engine for a step

Parameters

Request $request the active request
array $form The form fields
string $simu The simulator name
string $view &$view The view name
bool $test true if it is a test from the administration module, false otherwise

Return Value

Response|Step|null

in BaseController at line 580
protected void addWidget(string $widget)

Adds a widget to the list of widgets

Parameters

string $widget The widget name

Return Value

void

in BaseController at line 596
protected void widgetDeps(string $widget, array $widgets, array $availWidgets)

Adds widgets that depend on a widget in the list of widgets

Parameters

string $widget The widget name
array $widgets &$widgets the list of widgets
array $availWidgets &$availWidgets the list of available widgets

Return Value

void

in BaseController at line 615
protected void addFunction(string $function)

Adds a function to the list of functions

Parameters

string $function The function name

Return Value

void

in BaseController at line 631
protected void functionDeps(string $function, array $functions, array $availFunctions)

Adds functions that depend on a function in the list of functions

Parameters

string $function The function name
array $functions &$functions the list of functions
array $availFunctions &$availFunctions the list of available functions

Return Value

void

in BaseController at line 652
protected Response runFields(Request $request, string $simu, bool $test = false)

Returns the simulators attributes in JSON response format

Parameters

Request $request the active request
string $simu The simulator name
bool $test (default: false) true if it is a test from the administration module, false otherwise

Return Value

Response

in BaseController at line 673
protected Response runSource(Request $request, string $simu, bool $test = false)

Returns the requested source attributes in JSON response format

Parameters

Request $request the active request
string $simu The simulator name
bool $test (default: false) true if it is a test from the administration module, false otherwise

Return Value

Response

in BaseController at line 715
protected string getSimuPath(string $simu, bool $test = false)

Get the simulators directory

Parameters

string $simu The simulator name
bool $test (default: false) true if it is a test from the administration module, false otherwise

Return Value

string the simulators directory

in BaseController at line 743
protected void checkField(Field $field, array $form, bool $skipValidation)

Checks the given field

Parameters

Field $field
array $form The form fields
bool $skipValidation

Return Value

void

in BaseController at line 803
protected void processField(Field $field, Step $step, bool $displayable)

Processes the given field for the step

Parameters

Field $field
Step $step
bool $displayable &$displayable

Return Value

void

in BaseController at line 845
protected void replaceFieldNotes(Field $field)

Replaces data values in the notes of a field

Parameters

Field $field

Return Value

void

in BaseController at line 865
protected string|false evaluate(string $condition)

Evaluates a condition with the expression parser

Parameters

string $condition The condition to evaluate

Return Value

string|false Result of the evaluation

in BaseController at line 881
protected void evaluateDefault(Data $data)

Evaluates the default value of the given data

Parameters

Data $data

Return Value

void

in BaseController at line 900
protected void evaluateDefaults()

Evaluates the default value of all data

Return Value

void

in BaseController at line 922
protected void evaluateMin(Data $data)

Evaluates the minimum value of the given data

Parameters

Data $data

Return Value

void

in BaseController at line 944
protected void evaluateMax(Data $data)

Evaluates the maximum value of the given data

Parameters

Data $data

Return Value

void

in BaseController at line 965
protected void evaluateMinMax()

Evaluates the minimum and the maximum value of all data

Return Value

void

in BaseController at line 989
protected void processData(Data $data, int $istep)

Processes the given data for the step

Parameters

Data $data
int $istep The step number

Return Value

void

in BaseController at line 1120
protected void processActions(array $actions, int $istep)

Executes all the actions of a business rule of the step

Parameters

array $actions Actions of the business rule
int $istep The step number

Return Value

void

in BaseController at line 1330
protected void processRule(BusinessRule $businessrule, int $istep)

Evaluates the conditions of a business rule an executes the suitable actions

Parameters

BusinessRule $businessrule The rule to be processed
int $istep The step number

Return Value

void

in BaseController at line 1349
protected void processRules(int $istep)

Evaluates the conditions of all business rules an executes the suitable actions

Parameters

int $istep The step number

Return Value

void

in BaseController at line 1365
protected void processDatas(int $istep)

Processes all data for the step

Parameters

int $istep The step number

Return Value

void

at line 52
Response index(Request $request)

Entry point for the route path /

Parameters

Request $request The request

Return Value

Response

at line 66
protected Response runIndex(Request $request)

Dispatches the index action to the appropriate processing.

Parameters

Request $request The request

Return Value

Response