APIController
class APIController extends BaseController
This class deals with the API function of the simulation engine.
For a simulator to accept an API request, the following parameters must be defined in the "config/packages/g6k.yml" file:
api: <simulator name>: step: <step number> action: <action button name>
the API conforms to the JSON API
Traits
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 | |
private array | $datas | ||
private array | $metas | ||
private array | $errors |
Methods
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.
Constructor of class BaseController
Run the simulation engine for a step
Adds widgets that depend on a widget in the list of widgets
Adds functions that depend on a function in the list of functions
Returns the simulators attributes in JSON response format
Returns the requested source attributes in JSON response format
Get the simulators directory
Evaluates a condition with the expression parser
Executes all the actions of a business rule of the step
Evaluates the conditions of a business rule an executes the suitable actions
Evaluates the conditions of all business rules an executes the suitable actions
Run the simulation engine
Composes a parameter error
Composes an entity error
Details
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
in BaseController at line 105
void
__construct(TranslatorInterface $translator, KernelInterface $kernel, AuthorizationCheckerInterface $authorizationChecker, mixed $projectDir)
Constructor of class BaseController
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
in BaseController at line 580
protected void
addWidget(string $widget)
Adds a widget to the list of widgets
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
in BaseController at line 615
protected void
addFunction(string $function)
Adds a function to the list of functions
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
in BaseController at line 652
protected Response
runFields(Request $request, string $simu, bool $test = false)
Returns the simulators attributes in JSON response format
in BaseController at line 673
protected Response
runSource(Request $request, string $simu, bool $test = false)
Returns the requested source attributes in JSON response format
in BaseController at line 715
protected string
getSimuPath(string $simu, bool $test = false)
Get the simulators directory
in BaseController at line 743
protected void
checkField(Field $field, array $form, bool $skipValidation)
Checks the given field
in BaseController at line 803
protected void
processField(Field $field, Step $step, bool $displayable)
Processes the given field for the step
in BaseController at line 845
protected void
replaceFieldNotes(Field $field)
Replaces data values in the notes of a field
in BaseController at line 865
protected string|false
evaluate(string $condition)
Evaluates a condition with the expression parser
in BaseController at line 881
protected void
evaluateDefault(Data $data)
Evaluates the default value of the given data
in BaseController at line 900
protected void
evaluateDefaults()
Evaluates the default value of all data
in BaseController at line 922
protected void
evaluateMin(Data $data)
Evaluates the minimum value of the given data
in BaseController at line 944
protected void
evaluateMax(Data $data)
Evaluates the maximum value of the given data
in BaseController at line 965
protected void
evaluateMinMax()
Evaluates the minimum and the maximum value of all data
in BaseController at line 989
protected void
processData(Data $data, int $istep)
Processes the given data for the step
in BaseController at line 1120
protected void
processActions(array $actions, int $istep)
Executes all the actions of a business rule of the step
in BaseController at line 1330
protected void
processRule(BusinessRule $businessrule, int $istep)
Evaluates the conditions of a business rule an executes the suitable actions
in BaseController at line 1349
protected void
processRules(int $istep)
Evaluates the conditions of all business rules an executes the suitable actions
in BaseController at line 1365
protected void
processDatas(int $istep)
Processes all data for the step
at line 97
Response|Step
calcul(Request $request, string $simu)
The entry point of the API request
at line 111
Response|Step
tryIt(Request $request, string $simu)
The entry point of the API request in test mode
at line 126
protected Response|Step
runCalcul(Request $request, string $simu, bool $test = false)
Run the simulation engine
at line 160
protected Response
apiOutput(Request $request, array $form, Step $step)
Composes the API response
at line 289
private void
processApiField(array $form, Field $field)
Processes the API field
at line 315
private void
processApiFieldData(array $form, Data $data)
Processes the API field data
at line 332
private void
addResponseError(array $form, DatasetChild $data)
Add response error
at line 359
private void
addParameterError(string $parameter, string $title, string $detail)
Composes a parameter error
at line 381
private void
addEntityError(string $entity, string $title, string $detail)
Composes an entity error