trait ControllersTrait

This class implements common functions needed in G6KBundle controllers.

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

Details

at line 66
protected void initialize()

Initialization of common directories

Return Value

void

at line 81
KernelInterface getKernel()

Returns the Symfony kernel

Return Value

KernelInterface $kernel The Symfony kernel

at line 92
TranslatorInterface getTranslator()

Returns the translator interface

Return Value

TranslatorInterface The translator interface

at line 103
bool hasParameter($parameters)

Checks if a parameter exists or not

Parameters

$parameters

Return Value

bool true the parameter exists, false otherwise

at line 119
string getLocale()

Returns the 'locale' from config parameters

Return Value

string The locale

at line 130
string getLanguage()

Returns the 'app_language' from config parameters

Return Value

string The app_language

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

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

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

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.

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

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

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

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

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

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

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

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

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

at line 679
array getWidgets()

Returns the list of available widgets.

Return Value

array The list of available widgets

at line 696
array getWidgetsByType()

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

Return Value

array The list of available widgets

at line 726
array getWidgetsByInputType()

Returns the list of available widgets by form input type.

Return Value

array The list of available widgets

at line 756
array getFunctions()

Returns the label of available functions.

Return Value

array The label of available functions

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

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

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

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

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

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

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

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

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

at line 991
string getEnvironment()

Returns the current environment

Return Value

string The first letters of the current environment