/** * @param Node $node * @param $for */ private function addFilterNode(Node $node, $for) { if (!$this->environment->hasFunction('filter_' . $for)) { $for = $this->defaultAutofilterStrategy; } $node->addChild(new FunctionNode('filter_' . $for, [$node->getChild('expression')]), 'expression'); }
function template_function_filter(Environment $environment, $data, $for = 'html') { if (!is_string($data)) { return $data; } if (!$environment->hasFunction('filter_' . $for)) { $for = $environment->getOption('default_autofilter_strategy'); } return $environment->getFunction('filter_' . $for)->call($data); }
/** * @dataProvider functionProvider */ public function testFunctionsAreAddedToEnvironment($function) { $this->assertTrue($this->env->hasFunction($function)); }