vendor/doctrine/doctrine-bundle/Command/Proxy/RunSqlDoctrineCommand.php line 18

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
  3. use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
  4. use Doctrine\DBAL\Tools\Console\ConnectionProvider;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Input\InputOption;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use function trigger_deprecation;
  9. /**
  10.  * Execute a SQL query and output the results.
  11.  *
  12.  * @deprecated use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand instead
  13.  */
  14. class RunSqlDoctrineCommand extends RunSqlCommand
  15. {
  16.     /** @var ConnectionProvider|null */
  17.     private $connectionProvider;
  18.     public function __construct(?ConnectionProvider $connectionProvider null)
  19.     {
  20.         parent::__construct($connectionProvider);
  21.         $this->connectionProvider $connectionProvider;
  22.     }
  23.     protected function configure(): void
  24.     {
  25.         parent::configure();
  26.         $this
  27.             ->setName('doctrine:query:sql')
  28.             ->setHelp(<<<EOT
  29. The <info>%command.name%</info> command executes the given SQL query and
  30. outputs the results:
  31. <info>php %command.full_name% "SELECT * FROM users"</info>
  32. EOT
  33.         );
  34.         if ($this->getDefinition()->hasOption('connection')) {
  35.             return;
  36.         }
  37.         $this->addOption('connection'nullInputOption::VALUE_OPTIONAL'The connection to use for this command');
  38.     }
  39.     protected function execute(InputInterface $inputOutputInterface $output): int
  40.     {
  41.         trigger_deprecation(
  42.             'doctrine/doctrine-bundle',
  43.             '2.2',
  44.             'The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.',
  45.             self::class
  46.         );
  47.         if (! $this->connectionProvider) {
  48.             DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
  49.             // compatibility with doctrine/dbal 2.11+
  50.             // where this option is also present and unsupported before we are not switching to use a ConnectionProvider
  51.             $input->setOption('connection'null);
  52.         }
  53.         return parent::execute($input$output);
  54.     }
  55. }