Twig::addFunctions PHP Method

addFunctions() protected method

protected addFunctions ( )
    protected function addFunctions()
    {
        // Runs only once
        if ($this->functions_added) {
            return;
        }
        // as is functions
        foreach ($this->functions_asis as $function) {
            if (function_exists($function)) {
                $this->twig->addFunction(new \Twig_SimpleFunction($function, $function));
            }
        }
        // safe functions
        foreach ($this->functions_safe as $function) {
            if (function_exists($function)) {
                $this->twig->addFunction(new \Twig_SimpleFunction($function, $function, ['is_safe' => ['html']]));
            }
        }
        // customized functions
        if (function_exists('anchor')) {
            $this->twig->addFunction(new \Twig_SimpleFunction('anchor', [$this, 'safe_anchor'], ['is_safe' => ['html']]));
        }
        $this->functions_added = TRUE;
    }