DataCollector/TwigDataCollector.php
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $filters = array();
        $tests = array();
        $extensions = array();
        $functions = array();

        foreach ($this->getTwig()->getExtensions() as $extensionName => $extension) {
            $extensions[] = array(
                'name' => $extensionName,
                'class' => get_class($extension)
            );
            foreach ($extension->getFilters() as $filterName => $filter) {
                if ($filter instanceof \Twig_FilterInterface) {
                    $call = $filter->compile();
                    if (is_array($call) && is_callable($call)) {
                        $call = 'Method '.$call[1].' of an object '.get_class($call[0]);
                    }
                } else {
                    $call = $filter->getName();
                }

                $filters[] = array(
                    'name' => $filterName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }

            foreach ($extension->getTests() as $testName => $test) {
                if ($test instanceof \Twig_TestInterface) {
                    $call = $test->compile();
                } else {
                    $call = $test->getName();
                }

                $tests[] = array(
                    'name' => $testName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }

            foreach ($extension->getFunctions() as $functionName => $function) {
                if ($function instanceof \Twig_FunctionInterface) {
                    $call = $function->compile();
                } else {
                    $call = $function->getName();
                }

                $functions[] = array(
                    'name' => $functionName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }
        }

        $globals = array();

        foreach ($this->getTwig()->getGlobals() as $globalName => $global) {
            $globals[] = array(
                'name' => $globalName,
                'value' => $this->getVarDump($global),
            );
        }

        $this->data['globals'] = $globals;
        $this->data['extensions'] = $extensions;
        $this->data['tests'] = $tests;
        $this->data['filters'] = $filters;
        $this->data['functions'] = $functions;
    }
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $filters = array();
        $tests = array();
        $extensions = array();
        $functions = array();

        foreach ($this->getTwig()->getExtensions() as $extensionName => $extension) {
            $extensions[] = array(
                'name' => $extensionName,
                'class' => get_class($extension)
            );
            foreach ($extension->getFilters() as $filterName => $filter) {
                if ($filter instanceof \Twig_FilterInterface) {
                    $call = $filter->compile();
                    if (is_array($call) && is_callable($call)) {
                        $call = 'Method '.$call[1].' of an object '.get_class($call[0]);
                    }
                } else {
                    $call = $filter->getName();
                }

                $filters[] = array(
                    'name' => $filterName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }

            foreach ($extension->getTests() as $testName => $test) {
                if ($test instanceof \Twig_TestInterface) {
                    $call = $test->compile();
                } else {
                    $call = $test->getName();
                }

                $tests[] = array(
                    'name' => $testName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }

            foreach ($extension->getFunctions() as $functionName => $function) {
                if ($function instanceof \Twig_FunctionInterface) {
                    $call = $function->compile();
                } else {
                    $call = $function->getName();
                }

                $functions[] = array(
                    'name' => $functionName,
                    'extension' => $extensionName,
                    'call' => $call,
                );
            }
        }

        $globals = array();

        foreach ($this->getTwig()->getGlobals() as $globalName => $global) {
            $globals[] = array(
                'name' => $globalName,
                'value' => $this->getVarDump($global),
            );
        }

        $this->data['globals'] = $globals;
        $this->data['extensions'] = $extensions;
        $this->data['tests'] = $tests;
        $this->data['filters'] = $filters;
        $this->data['functions'] = $functions;
    }
public function collect ( Request $ request , Response $ response , \ Exception $ exception = null ) { $ filters = array ( ) ; $ tests = array ( ) ; $ extensions = array ( ) ; $ functions = array ( ) ; foreach ( $ this -> getTwig ( ) -> getExtensions ( ) as $ extensionName => $ extension ) { $ extensions [ ] = array ( 'name' => $ extensionName , 'class' => get_class ( $ extension ) ) ; foreach ( $ extension -> getFilters ( ) as $ filterName => $ filter ) { if ( $ filter instanceof \ Twig_FilterInterface ) { $ call = $ filter -> compile ( ) ; if ( is_array ( $ call ) && is_callable ( $ call ) ) { $ call = 'Method ' . $ call [ 1 ] . ' of an object ' . get_class ( $ call [ 0 ] ) ; } } else { $ call = $ filter -> getName ( ) ; } $ filters [ ] = array ( 'name' => $ filterName , 'extension' => $ extensionName , 'call' => $ call , ) ; } foreach ( $ extension -> getTests ( ) as $ testName => $ test ) { if ( $ test instanceof \ Twig_TestInterface ) { $ call = $ test -> compile ( ) ; } else { $ call = $ test -> getName ( ) ; } $ tests [ ] = array ( 'name' => $ testName , 'extension' => $ extensionName , 'call' => $ call , ) ; } foreach ( $ extension -> getFunctions ( ) as $ functionName => $ function ) { if ( $ function instanceof \ Twig_FunctionInterface ) { $ call = $ function -> compile ( ) ; } else { $ call = $ function -> getName ( ) ; } $ functions [ ] = array ( 'name' => $ functionName , 'extension' => $ extensionName , 'call' => $ call , ) ; } } $ globals = array ( ) ; foreach ( $ this -> getTwig ( ) -> getGlobals ( ) as $ globalName => $ global ) { $ globals [ ] = array ( 'name' => $ globalName , 'value' => $ this -> getVarDump ( $ global ) , ) ; } $ this -> data [ 'globals' ] = $ globals ; $ this -> data [ 'extensions' ] = $ extensions ; $ this -> data [ 'tests' ] = $ tests ; $ this -> data [ 'filters' ] = $ filters ; $ this -> data [ 'functions' ] = $ functions ; }
Collect information from Twig

@param Request    $request   The Request Object
@param Response   $response  The Response Object
@param \Exception $exception The Exception
Collect information from Twig