public function compile(Twig_Compiler $compiler)
{
$name = $this->getAttribute('name');
-
+
$function = $compiler->getEnvironment()->getFunction($name);
-
+
if (false === $function) {
$alternativeFunctions = array();
-
+
foreach ($compiler->getEnvironment()->getFunctions() as $functionName => $function) {
if (false !== strpos($functionName, $name)) {
$alternativeFunctions[] = $functionName;
}
}
-
+
$exceptionMessage = sprintf('The function "%s" does not exist', $name);
-
+
if (count($alternativeFunctions)) {
$exceptionMessage = sprintf('%s. Did you mean "%s"?', $exceptionMessage, implode('", "', $alternativeFunctions));
}
-
+
throw new Twig_Error_Syntax($exceptionMessage, $this->getLine());
}