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

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