public function Twig_Environment::addTest in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/Environment.php \Twig_Environment::addTest()
Registers a Test.
Parameters
string|Twig_SimpleTest $name The test name or a Twig_SimpleTest instance:
Twig_TestInterface|Twig_SimpleTest $test A Twig_TestInterface instance or a Twig_SimpleTest instance:
File
- vendor/
Twig/ Environment.php, line 876
Class
- Twig_Environment
- Stores the Twig configuration.
Code
public function addTest($name, $test = null) {
if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) {
throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest');
}
if ($name instanceof Twig_SimpleTest) {
$test = $name;
$name = $test
->getName();
}
if ($this->extensionInitialized) {
throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name));
}
$this->staging
->addTest($name, $test);
}