/** * @param ViewElement $viewElement */ public function evaluate(ViewElementTag $viewElement) { if ($this->function === null) { //Instantiate the Function handler: /** @var FunctionFactory[] $factories */ $factories = $viewElement->getView()->getFunctionFactories(); if (null != $factories && is_array($factories)) { foreach ($factories as $factory) { if (null !== ($this->function = $factory->lookup($this->name))) { break; } } } if ($this->function == null) { $logger = LoggerFactory::getLogger(__CLASS__); $message = 'Undeclared function: ' . $this->name; $logger->error($message); throw new FunctionNotFoundException($this->name); } } $arguments = array(); if ($this->operands) { foreach ($this->operands as $operandToken) { $arguments[] = $operandToken->evaluate($viewElement); } } return $this->function->evaluate($viewElement, $this->arity, $arguments); }