protected function addTwigFunction($name, $callback, $options = [])
    {
        // If we pass a callback as a simple string, we need to turn it into an array.
        if (is_string($callback) && method_exists($this, $callback)) {
            $callback = [$this, $callback];
        }

        $safe = method_exists($this, 'isSafe') && $this->isSafe();
        if (isset($options['safe'])) {
            $safe = (bool) $options['safe'];
            unset($options['safe']);
        }

        $this->twigFunctions[] = new TwigFunction($name, $callback, $options);

        if ($safe) {
            $this->safeFunctionNames[] = $name;
        }
    }
protected function addTwigFunction($name, $callback, $options = [])
    {
        // If we pass a callback as a simple string, we need to turn it into an array.
        if (is_string($callback) && method_exists($this, $callback)) {
            $callback = [$this, $callback];
        }

        $safe = method_exists($this, 'isSafe') && $this->isSafe();
        if (isset($options['safe'])) {
            $safe = (bool) $options['safe'];
            unset($options['safe']);
        }

        $this->twigFunctions[] = new TwigFunction($name, $callback, $options);

        if ($safe) {
            $this->safeFunctionNames[] = $name;
        }
    }
protected function addTwigFunction ( $ name , $ callback , $ options = [ ] ) { // If we pass a callback as a simple string, we need to turn it into an array. if ( is_string ( $ callback ) && method_exists ( $ this , $ callback ) ) { $ callback = [ $ this , $ callback ] ; } $ safe = method_exists ( $ this , 'isSafe' ) && $ this -> isSafe ( ) ; if ( isset ( $ options [ 'safe' ] ) ) { $ safe = ( bool ) $ options [ 'safe' ] ; unset ( $ options [ 'safe' ] ) ; } $ this -> twigFunctions [ ] = new TwigFunction ( $ name , $ callback , $ options ) ; if ( $ safe ) { $ this -> safeFunctionNames [ ] = $ name ; } }
Add a Twig Function.

@internal Will be made private in 4.0. Use registerTwigFunctions() instead.

@param string          $name
@param string|callable $callback
@param array           $options
Add a Twig Function .