From 9eee2e263f018bc1646fac1a5423dc6b711c581d Mon Sep 17 00:00:00 2001 From: rajasaur Date: Fri, 6 Dec 2013 12:13:53 +0530 Subject: [PATCH] Fix DumpCommand to generate html with/out sandbox api:doc:dump --format=html always disables the Sandbox since the check in DumpCommand seems to be wrong. Fixed that as well as introduce a dummy Request Object as the layout.html.twig expects an app.request object. --- Command/DumpCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Command/DumpCommand.php b/Command/DumpCommand.php index a47043f..03bf3d9 100644 --- a/Command/DumpCommand.php +++ b/Command/DumpCommand.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\HttpFoundation\Request; class DumpCommand extends ContainerAwareCommand { @@ -52,10 +53,15 @@ class DumpCommand extends ContainerAwareCommand $formatter = $this->getContainer()->get(sprintf('nelmio_api_doc.formatter.%s_formatter', $format)); } - if ($input->hasOption('no-sandbox') && 'html' === $format) { + if ($input->getOption('no-sandbox') && 'html' === $format) { $formatter->setEnableSandbox(false); } + if ('html' === $format) { + $this->getContainer()->enterScope('request'); + $this->getContainer()->set('request', new Request(), 'request'); + } + $extractedDoc = $this->getContainer()->get('nelmio_api_doc.extractor.api_doc_extractor')->all(); $formattedDoc = $formatter->format($extractedDoc);