fix deprecations

This commit is contained in:
Alexey Chelnakov 2022-09-26 13:04:14 +03:00
parent 8d699084aa
commit b5d96fcc11
3 changed files with 17 additions and 13 deletions

View File

@ -12,14 +12,16 @@
namespace Nelmio\ApiDocBundle\Command; namespace Nelmio\ApiDocBundle\Command;
use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class DumpCommand extends ContainerAwareCommand class DumpCommand extends Command implements ContainerAwareInterface
{ {
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
/** /**
* @var array * @var array
*/ */
@ -47,20 +49,20 @@ class DumpCommand extends ContainerAwareCommand
$format = $input->getOption('format'); $format = $input->getOption('format');
$view = $input->getOption('view'); $view = $input->getOption('view');
$routeCollection = $this->getContainer()->get('router')->getRouteCollection(); $routeCollection = $this->container->get('router')->getRouteCollection();
if ($format == 'json') { if ($format == 'json') {
$formatter = $this->getContainer()->get('nelmio_api_doc.formatter.simple_formatter'); $formatter = $this->container->get('nelmio_api_doc.formatter.simple_formatter');
} else { } else {
if (!in_array($format, $this->availableFormats)) { if (!in_array($format, $this->availableFormats)) {
throw new \RuntimeException(sprintf('Format "%s" not supported.', $format)); throw new \RuntimeException(sprintf('Format "%s" not supported.', $format));
} }
$formatter = $this->getContainer()->get(sprintf('nelmio_api_doc.formatter.%s_formatter', $format)); $formatter = $this->container->get(sprintf('nelmio_api_doc.formatter.%s_formatter', $format));
} }
if ($input->hasOption('locale')) { if ($input->hasOption('locale')) {
$this->getContainer()->get('translator')->setLocale($input->getOption('locale')); $this->container->get('translator')->setLocale($input->getOption('locale'));
} }
if ($input->hasOption('api-version')) { if ($input->hasOption('api-version')) {
@ -71,12 +73,12 @@ class DumpCommand extends ContainerAwareCommand
$formatter->setEnableSandbox(false); $formatter->setEnableSandbox(false);
} }
if ('html' === $format && method_exists($this->getContainer(), 'enterScope')) { if ('html' === $format && method_exists($this->container, 'enterScope')) {
$this->getContainer()->enterScope('request'); $this->container->enterScope('request');
$this->getContainer()->set('request', new Request(), 'request'); $this->container->set('request', new Request(), 'request');
} }
$extractor = $this->getContainer()->get('nelmio_api_doc.extractor.api_doc_extractor'); $extractor = $this->container->get('nelmio_api_doc.extractor.api_doc_extractor');
$extractedDoc = $input->hasOption('api-version') ? $extractedDoc = $input->hasOption('api-version') ?
$extractor->allForVersion($input->getOption('api-version'), $view) : $extractor->allForVersion($input->getOption('api-version'), $view) :
$extractor->all($view); $extractor->all($view);
@ -88,5 +90,7 @@ class DumpCommand extends ContainerAwareCommand
} else { } else {
$output->writeln($formattedDoc, OutputInterface::OUTPUT_RAW); $output->writeln($formattedDoc, OutputInterface::OUTPUT_RAW);
} }
return 0;
} }
} }

View File

@ -60,8 +60,8 @@ class DescriptionFormTypeExtension extends AbstractTypeExtension
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getExtendedType() public function getExtendedTypes()
{ {
return LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\FormType'); return [LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\FormType')];
} }
} }

View File

@ -1,4 +1,4 @@
nelmio_api_doc_index: nelmio_api_doc_index:
path: /{view} path: /{view}
defaults: { _controller: NelmioApiDocBundle:ApiDoc:index, view: 'default' } defaults: { _controller: Nelmio\ApiDocBundle\Controller\ApiDocController::indexAction, view: 'default' }
methods: [GET] methods: [GET]