TYPO3  7.6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BooleanNode Class Reference
Inheritance diagram for BooleanNode:
AbstractNode NodeInterface

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 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 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\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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 98 of file BooleanNode.php.

References AbstractNode\$childNodes, BooleanNode\$syntaxTreeNode, elseif, and BooleanNode\getComparatorFromString().

Member Function Documentation

static 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
bool

Definition at line 326 of file BooleanNode.php.

Parameters
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface$renderingContext
Returns
bool the boolean value

Implements NodeInterface.

Definition at line 195 of file BooleanNode.php.

static 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
bool TRUE if comparison of left and right side using the comparator emit TRUE, false otherwise
Exceptions
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 225 of file BooleanNode.php.

References BooleanNode\$comparator.

getComparator ( )
Returns
string

Definition at line 159 of file BooleanNode.php.

References BooleanNode\$comparator.

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 308 of file BooleanNode.php.

References BooleanNode\$comparator.

Referenced by BooleanNode\__construct().

getLeftSide ( )
Returns

Definition at line 177 of file BooleanNode.php.

References BooleanNode\$leftSide.

getRightSide ( )
Returns

Definition at line 186 of file BooleanNode.php.

References BooleanNode\$rightSide.

getSyntaxTreeNode ( )
Returns

Definition at line 168 of file BooleanNode.php.

References BooleanNode\$syntaxTreeNode.

static 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
bool TRUE if the operands can be compared using arithmetic operators, FALSE otherwise.

Definition at line 280 of file BooleanNode.php.

Member Data Documentation

$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
protected
$comparators = array('==', '!=', '%', '>=', '>', '<=', '<')
staticprotected

Definition at line 28 of file BooleanNode.php.

$leftSide
protected

Definition at line 65 of file BooleanNode.php.

Referenced by BooleanNode\getLeftSide().

$rightSide
protected

Definition at line 72 of file BooleanNode.php.

Referenced by BooleanNode\getRightSide().

$syntaxTreeNode
protected

Definition at line 89 of file BooleanNode.php.

Referenced by BooleanNode\__construct(), and BooleanNode\getSyntaxTreeNode().