‪TYPO3CMS  9.5
TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher Class Reference
Inheritance diagram for TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher:
TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher

Public Member Functions

 setPageId ($pageId)
 
int getPageId ()
 
 setRootline (array $rootline)
 
array getRootline ()
 
 setSimulateMatchResult ($simulateMatchResult)
 
 setSimulateMatchConditions (array $simulateMatchConditions)
 
bool match ($expression)
 

Protected Member Functions

 initializeExpressionLanguageResolver ()
 
 updateExpressionLanguageVariables ()
 
bool strictSyntaxEnabled ()
 
string normalizeExpression ($expression)
 
bool null evaluateExpression (string $expression)
 
bool null evaluateConditionCommon ($key, $value)
 
bool null evaluateCustomDefinedCondition ($condition)
 
array parseUserFuncArguments ($arguments)
 
mixed getVariableCommon (array $vars)
 
bool compareNumber ($test, $leftValue)
 
bool searchStringWildcard ($haystack, $needle)
 
mixed getGlobal ($var, $source=null)
 
bool evaluateCondition ($string)
 
mixed getVariable ($name)
 
string getGroupList ()
 
int determinePageId ()
 
array getPage ()
 
array determineRootline ()
 
int getUserId ()
 
bool isUserLoggedIn ()
 

Protected Attributes

int $pageId
 
array $rootline
 
bool $simulateMatchResult = false
 
array $simulateMatchConditions = array( )
 
Resolver $expressionLanguageResolver
 
array $expressionLanguageResolverVariables = array( )
 

Detailed Description

Matching TypoScript conditions

Used with the TypoScript parser. Matches IPnumbers etc. for use with templates

Definition at line 36 of file AbstractConditionMatcher.php.

Member Function Documentation

◆ compareNumber()

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::compareNumber (   $test,
  $leftValue 
)
protected

Evaluates a $leftValue based on an operator: "<", ">", "<=", ">=", "!=" or "="

Parameters
string$test‪The value to compare with on the form [operator][number]. Eg. "< 123
float$leftValue‪The value on the left side
Returns
‪bool If $value is "50" and $test is "< 123" then it will return TRUE.
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Definition at line 613 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ determinePageId()

int TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::determinePageId ( )
abstractprotected

◆ determineRootline()

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::determineRootline ( )
abstractprotected

Determines the rootline for the current page.

Returns
‪array The rootline for the current page.
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Reimplemented in TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher, and TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\match().

◆ evaluateCondition()

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateCondition (   $string)
abstractprotected

Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"

Parameters
string$string‪The condition to match against its criteria.
Returns
‪bool Whether the condition matched
See also
‪\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parse()
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Reimplemented in TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher, and TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\match().

◆ evaluateConditionCommon()

bool null TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateConditionCommon (   $key,
  $value 
)
protected

◆ evaluateCustomDefinedCondition()

bool null TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateCustomDefinedCondition (   $condition)
protected

Evaluates a TypoScript condition given as input with a custom class name, e.g. "[MyCompany\MyPackage\ConditionMatcher\MyOwnConditionMatcher = myvalue]"

Parameters
string$condition‪The condition to match
Returns
‪bool|null Result of the evaluation; NULL if condition could not be evaluated
Exceptions

Definition at line 490 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\parseUserFuncArguments().

Referenced by TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\evaluateCondition(), and TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\evaluateCondition().

◆ evaluateExpression()

bool null TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateExpression ( string  $expression)
protected

◆ getGlobal()

mixed TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getGlobal (   $var,
  $source = null 
)
protected

Return global variable where the input string $var defines array keys separated by "|" Example: $var = "HTTP_SERVER_VARS | something" will return the value $GLOBALS['HTTP_SERVER_VARS']['something'] value

Parameters
string$var‪Global var key, eg. "HTTP_GET_VAR" or "HTTP_GET_VARS|id" to get the GET parameter "id" back.
array$source‪Alternative array than $GLOBAL to get variables from.
Returns
‪mixed Whatever value. If none, then blank string.
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Definition at line 684 of file AbstractConditionMatcher.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\getVariable(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getVariableCommon().

◆ getGroupList()

string TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getGroupList ( )
abstractprotected

Gets the usergroup list of the current user.

Returns
‪string The usergroup list of the current user
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Reimplemented in TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher, and TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.

◆ getPage()

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getPage ( )
abstractprotected

◆ getPageId()

int TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getPageId ( )

Gets the id of the page to evaluate conditions for.

Returns
‪int Id of the page

Definition at line 116 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$pageId.

◆ getRootline()

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getRootline ( )

Gets the rootline.

Returns
‪array The rootline to be used for matching

Definition at line 139 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$rootline.

◆ getUserId()

int TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getUserId ( )
abstractprotected

◆ getVariable()

mixed TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getVariable (   $name)
abstractprotected

Gets the value of a variable.

Examples of names:

  • ‪TSFE:id
  • ‪GP:firstLevel|secondLevel
  • ‪_GET|firstLevel|secondLevel
  • ‪LIT:someLiteralValue
Parameters
string$name‪The name of the variable to fetch the value from
Returns
‪mixed The value of the given variable (string) or NULL if variable did not exist
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Reimplemented in TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher, and TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ getVariableCommon()

mixed TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getVariableCommon ( array  $vars)
protected

◆ initializeExpressionLanguageResolver()

◆ isUserLoggedIn()

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::isUserLoggedIn ( )
abstractprotected

◆ match()

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::match (   $expression)

Matches a TypoScript condition expression.

Parameters
string$expression‪The expression to match
Returns
‪bool Whether the expression matched

Definition at line 226 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$simulateMatchResult, TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\determinePageId(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\determineRootline(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateCondition(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateExpression(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\normalizeExpression(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\strictSyntaxEnabled().

Referenced by TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\loginUserConditionDoesNotMatchIfNotUserIsLoggedId(), TYPO3\CMS\Frontend\Tests\UnitDeprecated\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\loginUserConditionDoesNotMatchIfNotUserIsLoggedId(), TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\loginUserConditionMatchIfUserIsNotLoggedIn(), TYPO3\CMS\Frontend\Tests\UnitDeprecated\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\loginUserConditionMatchIfUserIsNotLoggedIn(), TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionDoesNotMatchDefaulUserGroupIds(), TYPO3\CMS\Frontend\Tests\UnitDeprecated\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionDoesNotMatchDefaulUserGroupIds(), TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionMatchesMultipleUserGroupId(), TYPO3\CMS\Frontend\Tests\UnitDeprecated\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionMatchesMultipleUserGroupId(), TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionMatchesSingleGroupId(), and TYPO3\CMS\Frontend\Tests\UnitDeprecated\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\usergroupConditionMatchesSingleGroupId().

◆ normalizeExpression()

string TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::normalizeExpression (   $expression)
protected

Normalizes an expression

  • ‪OR normalization: "...]OR[...", "...]||[...", "...][..." --> "...]||[..."
  • ‪AND normalization: "...]AND[...", "...]&&[..." --> "...]&&[..."
Parameters
string$expression‪The expression to be normalized (e.g. "[A] && [B] OR [C]")
Returns
‪string The normalized expression (e.g. "[A]&&[B]||[C]")
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Definition at line 175 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\match().

◆ parseUserFuncArguments()

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::parseUserFuncArguments (   $arguments)
protected

◆ searchStringWildcard()

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::searchStringWildcard (   $haystack,
  $needle 
)
protected

Matching two strings against each other, supporting a "*" wildcard or (if wrapped in "/") PCRE regular expressions

Parameters
string$haystack‪The string in which to find $needle.
string$needle‪The string to find in $haystack
Returns
‪bool Returns TRUE if $needle matches or is found in (according to wildcards) in $haystack. Eg. if $haystack is "Netscape 6.5" and $needle is "Net*" or "Net*ape" then it returns TRUE.
Deprecated:
‪since TYPO3 v9.4, will be removed in TYPO3 v10.0.

Definition at line 670 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Utility\StringUtility\searchStringWildcard().

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ setPageId()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setPageId (   $pageId)

◆ setRootline()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setRootline ( array  $rootline)

◆ setSimulateMatchConditions()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setSimulateMatchConditions ( array  $simulateMatchConditions)

Sets whether to simulate the behaviour and match specific conditions.

Parameters
array$simulateMatchConditions‪Conditions to simulate a match for

Definition at line 161 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$simulateMatchConditions.

◆ setSimulateMatchResult()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setSimulateMatchResult (   $simulateMatchResult)

Sets whether to simulate the behaviour and match all conditions.

Parameters
bool$simulateMatchResult‪Whether to simulate positive matches

Definition at line 149 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$simulateMatchResult.

◆ strictSyntaxEnabled()

◆ updateExpressionLanguageVariables()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::updateExpressionLanguageVariables ( )
protected

Member Data Documentation

◆ $expressionLanguageResolver

Resolver TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$expressionLanguageResolver
protected

Definition at line 68 of file AbstractConditionMatcher.php.

◆ $expressionLanguageResolverVariables

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$expressionLanguageResolverVariables = array( )
protected

Definition at line 72 of file AbstractConditionMatcher.php.

◆ $pageId

◆ $rootline

◆ $simulateMatchConditions

array TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$simulateMatchConditions = array( )
protected

Whether to simulat the behaviour and match specific conditions (used in TypoScript object browser).

Definition at line 64 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\setSimulateMatchConditions().

◆ $simulateMatchResult

bool TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$simulateMatchResult = false
protected