Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TwigBundle] Command twig:debug #9832

Closed
sirian opened this issue Dec 20, 2013 · 1 comment
Closed

[TwigBundle] Command twig:debug #9832

sirian opened this issue Dec 20, 2013 · 1 comment

Comments

@sirian
Copy link
Contributor

sirian commented Dec 20, 2013

What about adding twig:debug command which displays information about registered extensions, globals, functions, variables, etc..

like this

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $twig = $this->getContainer()->get('twig');

        $output->writeln('<info>Extensions</info>');
        foreach ($twig->getExtensions() as $extension) {
            $output->writeln(sprintf('  %-30s: %s', $extension->getName(), get_class($extension)));
        }

        if ($twig->getGlobals()) {
            $output->writeln('');
            $output->writeln('<info>Globals</info>');
            foreach ($twig->getGlobals() as $key => $value) {
                $output->writeln(sprintf('  %s', $key));
            }
        }


        if ($twig->getFunctions()) {
            $output->writeln('');
            $output->writeln('<info>Functions</info>');
            foreach ($twig->getFunctions() as $name => $function) {
                if ($function instanceof \Twig_SimpleFunction) {
                    $name = $function->getName();
                }
                $output->writeln(sprintf('  %s', $name));
            }
        }

        if ($twig->getFilters()) {
            $output->writeln('');
            $output->writeln('<info>Filters</info>');
            foreach ($twig->getFilters() as $name => $filter) {
                if ($filter instanceof \Twig_SimpleFilter) {
                    $name = $filter->getName();
                }
                $output->writeln(sprintf('  %s', $name));
            }
        }
    }
@cs278
Copy link
Contributor

cs278 commented Dec 20, 2013

#9818

@fabpot fabpot closed this as completed Dec 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants