class ControllersHelper

This class implements common functions needed in G6KBundle controllers.

Properties

private BaseAdminController|BaseController $controller
private ContainerInterface $container

Methods

void
__construct(BaseAdminController|BaseController $controller, ContainerInterface $container)

Constructor of class ControllersHelper

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.

string
replaceVariables(string $target)

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

string
replaceVariableTag(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.

string
replaceVarTagByVariable(string $target)

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

array
getWidgets()

Returns the list of available widgets.

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

DateTime|null
parseDate(string $format, string $dateStr)

Parses a date string to the given format and converts it to a DateTime object

bool
isDevelopmentEnvironment()

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

Details

at line 73
void __construct(BaseAdminController|BaseController $controller, ContainerInterface $container)

Constructor of class ControllersHelper

Parameters

BaseAdminController|BaseController $controller The controller that uses this helper
ContainerInterface $container The service container instance

Return Value

void

at line 91
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 138
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 156
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 301
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 325
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 364
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 407
string replaceVariables(string $target)

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

Parameters

string $target The target text

Return Value

string The result text

at line 429
protected string replaceVariableTag(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 446
string replaceVarTagByVariable(string $target)

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

Parameters

string $target The target text

Return Value

string The result text

at line 462
array getWidgets()

Returns the list of available widgets.

Return Value

array The list of available widgets

at line 480
Data 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 The Data object

at line 493
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 511
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 534
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 559
DateTime|null parseDate(string $format, string $dateStr)

Parses a date string to the given format and converts it to a DateTime object

Parameters

string $format The given format
string $dateStr The date to be converted

Return Value

DateTime|null The DateTime object

Exceptions

Exception

at line 578
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