TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode:
TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface Tx_Fluid_Core_Parser_SyntaxTree_BooleanNode

Public Member Functions

 __construct (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode)
 
 getComparator ()
 
 getSyntaxTreeNode ()
 
 getLeftSide ()
 
 getRightSide ()
 
 evaluate (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode
 evaluateChildNodes (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 getChildNodes ()
 
 addChildNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $childNode)
 

Static Public Member Functions

static evaluateComparator ($comparator, $evaluatedLeftSide, $evaluatedRightSide)
 
static convertToBoolean ($value)
 

Protected Member Functions

 getComparatorFromString ($string)
 

Static Protected Member Functions

static isComparable ($evaluatedLeftSide, $evaluatedRightSide)
 

Protected Attributes

 $leftSide
 
 $rightSide
 
 $comparator
 
 $syntaxTreeNode
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode
 $childNodes = array()
 

Static Protected Attributes

static $comparators = array('==', '!=', '%', '>=', '>', '<=', '<')
 
static $booleanExpressionTextNodeCheckerRegularExpression
 

Detailed Description

A node which is used inside boolean arguments

Definition at line 17 of file BooleanNode.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::__construct ( \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode  $syntaxTreeNode)

Constructor. Parses the syntax tree node and fills $this->leftSide, $this->rightSide, $this->comparator and $this->syntaxTreeNode.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode$syntaxTreeNode
Exceptions

Definition at line 98 of file BooleanNode.php.

References TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode\$childNodes, TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\$syntaxTreeNode, and TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\getComparatorFromString().

Member Function Documentation

◆ convertToBoolean()

static TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::convertToBoolean (   $value)
static

Convert argument strings to their equivalents. Needed to handle strings with a boolean meaning.

Must be public and static as it is used from inside cached templates.

Parameters
mixed$valueValue to be converted to boolean
Returns
boolean

Definition at line 317 of file BooleanNode.php.

◆ evaluate()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::evaluate ( \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface  $renderingContext)
Parameters
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface$renderingContext
Returns
boolean the boolean value

Implements TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface.

Definition at line 190 of file BooleanNode.php.

◆ evaluateComparator()

static TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::evaluateComparator (   $comparator,
  $evaluatedLeftSide,
  $evaluatedRightSide 
)
static

Do the actual comparison. Compares $leftSide and $rightSide with $comparator and emits a boolean value.

Some special rules apply:

  • The == and != operators are comparing the Object Identity using === and !==, when one of the two operands are objects.
  • For arithmetic comparisons (%, >, >=, <, <=), some special rules apply:
    • arrays are only comparable with arrays, else the comparison yields FALSE
    • objects are only comparable with objects, else the comparison yields FALSE
    • the comparison is FALSE when two types are not comparable according to the table "Comparison with various types" on http://php.net/manual/en/language.operators.comparison.php

This function must be static public, as it is also directly called from cached templates.

Parameters
string$comparator
mixed$evaluatedLeftSide
mixed$evaluatedRightSide
Returns
boolean TRUE if comparison of left and right side using the comparator emit TRUE, false otherwise
Exceptions

Definition at line 219 of file BooleanNode.php.

References TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\$comparator.

◆ getComparator()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::getComparator ( )
Returns
string

Definition at line 158 of file BooleanNode.php.

References TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\$comparator.

◆ getComparatorFromString()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::getComparatorFromString (   $string)
protected

Determine if there is a comparator inside $string, and if yes, returns it.

Parameters
string$stringstring to check for a comparator inside
Returns
string The comparator or NULL if none found.

Definition at line 300 of file BooleanNode.php.

References TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\$comparator.

Referenced by TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\__construct().

◆ getLeftSide()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::getLeftSide ( )
Returns

Definition at line 174 of file BooleanNode.php.

References TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode\$leftSide.

◆ getRightSide()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::getRightSide ( )

◆ getSyntaxTreeNode()

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::getSyntaxTreeNode ( )

◆ isComparable()

static TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::isComparable (   $evaluatedLeftSide,
  $evaluatedRightSide 
)
staticprotected

Checks whether two operands are comparable (based on their types). This implements the "Comparison with various types" table from http://php.net/manual/en/language.operators.comparison.php, only leaving out "array" with "anything" and "object" with anything; as we specify that arrays and objects are incomparable with anything else than their type.

Parameters
mixed$evaluatedLeftSide
mixed$evaluatedRightSide
Returns
boolean TRUE if the operands can be compared using arithmetic operators, FALSE otherwise.

Definition at line 273 of file BooleanNode.php.

Member Data Documentation

◆ $booleanExpressionTextNodeCheckerRegularExpression

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::$booleanExpressionTextNodeCheckerRegularExpression
staticprotected
Initial value:
= '/
^ # Start with first input symbol
(?: # start repeat
COMPARATORS # We allow all comparators
|\s* # Arbitary spaces
|-? # Numbers, possibly with the "minus" symbol in front.
[0-9]+ # some digits
(?: # and optionally a dot, followed by some more digits
\\.
[0-9]+
)?
|\'[^\'\\\\]* # single quoted string literals with possibly escaped single quotes
(?:
\\\\. # escaped character
[^\'\\\\]* # unrolled loop following Jeffrey E.F. Friedl
)*\'
|"[^"\\\\]* # double quoted string literals with possibly escaped double quotes
(?:
\\\\. # escaped character
[^"\\\\]* # unrolled loop following Jeffrey E.F. Friedl
)*"
)*
$/x'

Definition at line 36 of file BooleanNode.php.

◆ $comparator

◆ $comparators

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::$comparators = array('==', '!=', '%', '>=', '>', '<=', '<')
staticprotected

Definition at line 28 of file BooleanNode.php.

◆ $leftSide

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::$leftSide
protected

◆ $rightSide

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::$rightSide
protected

◆ $syntaxTreeNode

TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\BooleanNode::$syntaxTreeNode
protected