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.     /**
  24.      * {@inheritDoc}
  25.      */
  26.     protected function configure()
  27.     {
  28.         parent::configure();
  29.         $this
  30.             ->setName('doctrine:query:sql')
  31.             ->setHelp(<<<EOT
  32. The <info>%command.name%</info> command executes the given SQL query and
  33. outputs the results:
  34. <info>php %command.full_name% "SELECT * FROM users"</info>
  35. EOT
  36.         );
  37.         if ($this->getDefinition()->hasOption('connection')) {
  38.             return;
  39.         }
  40.         $this->addOption('connection'nullInputOption::VALUE_OPTIONAL'The connection to use for this command');
  41.     }
  42.     /**
  43.      * {@inheritDoc}
  44.      */
  45.     protected function execute(InputInterface $inputOutputInterface $output)
  46.     {
  47.         trigger_deprecation(
  48.             'doctrine/doctrine-bundle',
  49.             '2.2',
  50.             'The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.',
  51.             self::class
  52.         );
  53.         if (! $this->connectionProvider) {
  54.             DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
  55.             // compatibility with doctrine/dbal 2.11+
  56.             // where this option is also present and unsupported before we are not switching to use a ConnectionProvider
  57.             $input->setOption('connection'null);
  58.         }
  59.         return parent::execute($input$output);
  60.     }
  61. }