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.
This commit is contained in:
rajasaur 2013-12-06 12:13:53 +05:30
parent 2ceea4871a
commit 9eee2e263f

View File

@ -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);