EvaluateDisplayConditions implements FormDataProviderInterface

Class EvaluateDisplayConditions implements the TCA 'displayCond' option.

The display condition is a colon separated string which describes the condition to decide whether a form field should be displayed.

Table of Contents

Interfaces

FormDataProviderInterface
Interface must be implemented by form data provider classes.

Methods

addData()  : array<string|int, mixed>
Remove fields from processedTca columns that should not be displayed.
evaluateConditionRecursive()  : bool
Evaluate a condition recursive by evaluating the single condition type
evaluateConditions()  : array<string|int, mixed>
Loop through TCA, find prepared conditions and evaluate them. Delete either the field itself if the condition did not match, or the 'displayCond' in TCA.
findFieldValue()  : mixed
Find field value the condition refers to for "FIELD:" conditions. For "normal" TCA fields this is the value of a "neighbor" field, but in flex form context it can be prepended with a sheet name. The method sorts out the details and returns the current field value.
getBackendUser()  : BackendUserAuthentication
matchFieldCondition()  : bool
Evaluates conditions concerning a field of the current record.
matchRecordCondition()  : bool
Evaluates conditions concerning the status of the current record.
matchUserCondition()  : bool
Evaluates via the referenced user-defined method
matchVersionCondition()  : bool
Evaluates whether the current record is versioned.
parseConditionRecursive()  : array<string|int, mixed>
Parse a condition into an array representation and validate syntax. Handles nested conditions combined with AND and OR.
parseDisplayConditions()  : array<string|int, mixed>
Find all 'displayCond' in TCA and flex forms and substitute them with an array representation that contains all relevant data to evaluate the condition later. For "FIELD" conditions the helper methods findFieldValue() is used to find the value of the referenced field to put that value into the returned array, too. This is important since the referenced field is "relative" to the position of the field that has the display condition.
parseSingleConditionString()  : array<string|int, mixed>
Parse a single condition string into pieces, validate them and return an array representation.

Methods

addData()

Remove fields from processedTca columns that should not be displayed.

public addData(array<string|int, mixed> $result) : array<string|int, mixed>

Strategy of the parser is to first find all displayCond in given tca and within all type=flex fields to parse them into an array. This condition array contains all information to evaluate that condition in a second step that - depending on evaluation result - then throws away or keeps the field.

Parameters
$result : array<string|int, mixed>
Return values
array<string|int, mixed>

Result filled with more data

evaluateConditionRecursive()

Evaluate a condition recursive by evaluating the single condition type

protected evaluateConditionRecursive(array<string|int, mixed> $conditionArray) : bool
Parameters
$conditionArray : array<string|int, mixed>

The condition to evaluate, possibly with subConditions for AND and OR types

Return values
bool

true if the condition matched

evaluateConditions()

Loop through TCA, find prepared conditions and evaluate them. Delete either the field itself if the condition did not match, or the 'displayCond' in TCA.

protected evaluateConditions(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>
Return values
array<string|int, mixed>

findFieldValue()

Find field value the condition refers to for "FIELD:" conditions. For "normal" TCA fields this is the value of a "neighbor" field, but in flex form context it can be prepended with a sheet name. The method sorts out the details and returns the current field value.

protected findFieldValue(string $givenFieldName, array<string|int, mixed> $databaseRow[, array<string|int, mixed> $flexContext = [] ]) : mixed
Parameters
$givenFieldName : string

The full name used in displayCond. Can have sheet names included in flex context

$databaseRow : array<string|int, mixed>

Incoming database row values

$flexContext : array<string|int, mixed> = []

Detailed flex context if display condition is within a flex field, needed to determine field value for "FIELD" conditions

Tags
throws
RuntimeException
Return values
mixed

The current field value from database row or a deeper flex form structure field.

matchFieldCondition()

Evaluates conditions concerning a field of the current record.

protected matchFieldCondition(array<string|int, mixed> $condition) : bool

Example: "FIELD:sys_language_uid:>:0" => TRUE, if the field 'sys_language_uid' is greater than 0

Parameters
$condition : array<string|int, mixed>

Condition array

Return values
bool

matchRecordCondition()

Evaluates conditions concerning the status of the current record.

protected matchRecordCondition(array<string|int, mixed> $condition) : bool

Example: "REC:NEW:FALSE" => TRUE, if the record is already persisted (has a uid > 0)

Parameters
$condition : array<string|int, mixed>

Condition array

Return values
bool

matchUserCondition()

Evaluates via the referenced user-defined method

protected matchUserCondition(array<string|int, mixed> $condition) : bool
Parameters
$condition : array<string|int, mixed>

Condition array

Return values
bool

matchVersionCondition()

Evaluates whether the current record is versioned.

protected matchVersionCondition(array<string|int, mixed> $condition) : bool
Parameters
$condition : array<string|int, mixed>

Condition array

Return values
bool

parseConditionRecursive()

Parse a condition into an array representation and validate syntax. Handles nested conditions combined with AND and OR.

protected parseConditionRecursive(mixed $condition, array<string|int, mixed> $databaseRow[, array<string|int, mixed> $flexContext = [] ]) : array<string|int, mixed>

Calls itself recursive for nesting and logically combined conditions.

Parameters
$condition : mixed

Either an array with multiple conditions combined with AND or OR, or a single condition string

$databaseRow : array<string|int, mixed>

Incoming full database row

$flexContext : array<string|int, mixed> = []

Detailed flex context if display condition is within a flex field, needed to determine field value for "FIELD" conditions

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

Array representation of that condition, see unit tests for details on syntax

parseDisplayConditions()

Find all 'displayCond' in TCA and flex forms and substitute them with an array representation that contains all relevant data to evaluate the condition later. For "FIELD" conditions the helper methods findFieldValue() is used to find the value of the referenced field to put that value into the returned array, too. This is important since the referenced field is "relative" to the position of the field that has the display condition.

protected parseDisplayConditions(array<string|int, mixed> $result) : array<string|int, mixed>

For instance, "FIELD:aField:=:foo" within a flex form field references a field value from the same sheet, and there are many more complex scenarios to resolve.

Parameters
$result : array<string|int, mixed>

Incoming result array

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

Modified result array with all displayCond parsed into arrays

parseSingleConditionString()

Parse a single condition string into pieces, validate them and return an array representation.

protected parseSingleConditionString(string $conditionString, array<string|int, mixed> $databaseRow[, array<string|int, mixed> $flexContext = [] ]) : array<string|int, mixed>
Parameters
$conditionString : string

Given condition string like "VERSION:IS:true"

$databaseRow : array<string|int, mixed>

Incoming full database row

$flexContext : array<string|int, mixed> = []

Detailed flex context if display condition is within a flex field, needed to determine field value for "FIELD" conditions

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

Validated name array, example: [ type="VERSION", isVersion="true" ]


        
On this page

Search results