1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<?php
declare(strict_types=1);
namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
/**
* Command to ensure that Doctrine is properly configured for a production environment.
*
* @deprecated
*
* @link www.doctrine-project.org
*/
class EnsureProductionSettingsCommand extends AbstractEntityManagerCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('orm:ensure-production-settings')
->setDescription('Verify that Doctrine is properly configured for a production environment')
->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on')
->addOption('complete', null, InputOption::VALUE_NONE, 'Flag to also inspect database connection existence.')
->setHelp('Verify that Doctrine is properly configured for a production environment.');
}
/**
* {@inheritdoc}
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();
$ui->warning('This console command has been deprecated and will be removed in a future version of Doctrine ORM.');
$em = $this->getEntityManager($input);
try {
$em->getConfiguration()->ensureProductionSettings();
if ($input->getOption('complete') === true) {
$em->getConnection()->connect();
}
} catch (Throwable $e) {
$ui->error($e->getMessage());
return 1;
}
$ui->success('Environment is correctly configured for production.');
return 0;
}
}
|