public function TokenReplacerBase::test in Forena Reports 8
Same name and namespace in other branches
- 7.5 src/Token/TokenReplacerBase.php \Drupal\forena\Token\TokenReplacerBase::test()
Test for TRUE/FALSE for conditions that are able to be represented using bind parameters Note that & are used to separate the different conditions and these are to be OR'd together.
Parameters
$condition String:
Return value
bool Boolean cast of expression.
Overrides TokenReplacerInterface::test
File
- src/
Token/ TokenReplacerBase.php, line 178 - FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.
Class
- TokenReplacerBase
- Base class for token replacements. @package Drupal\forena\Token
Namespace
Drupal\forena\TokenCode
public function test($condition) {
$eval = TRUE;
$tests = explode('&', $condition);
if ($tests) {
foreach ($tests as $test) {
$t = trim($test);
$res = $this
->replace($t, TRUE);
if (is_string($res)) {
$res = trim($res, ' !') ? TRUE : FALSE;
if (strpos($t, '!') === 0) {
$res = !$res;
}
}
else {
$res = $res ? TRUE : FALSE;
}
$eval = $eval && $res;
}
}
return $eval;
}