Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use error style for notifications #10162

Merged
merged 1 commit into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"doctrine/lexer": "^1.2.3",
"doctrine/persistence": "^2.4 || ^3",
"psr/cache": "^1 || ^2 || ^3",
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0",
"symfony/console": "^3.3 || ^4.0 || ^5.0 || ^6.0",
"symfony/polyfill-php72": "^1.23",
"symfony/polyfill-php80": "^1.16"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$ownerClass = $input->getArgument('owner-class');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$entityClass = $input->getArgument('entity-class');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$cacheDriver = $em->getConfiguration()->getMetadataCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$cache = $em->getConfiguration()->getQueryCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$name = $input->getArgument('region-name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$cache = $em->getConfiguration()->getResultCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');
$ui->getErrorStyle()->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');

// Process source directories
$fromPaths = array_merge([$input->getArgument('from-path')], $input->getOption('from'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');
$ui->getErrorStyle()->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');

$em = $this->getEntityManager($input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class is supposed to extend which. You have to adjust the entity
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();
$ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');

$em = $this->getEntityManager($input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();
$ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.');

$em = $this->getEntityManager($input);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$entityManager = $this->getEntityManager($input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$entityManager = $this->getEntityManager($input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$metadatas = $em->getMetadataFactory()->getAllMetadata();

if (empty($metadatas)) {
$ui->success('No Metadata Classes to process.');
$ui->getErrorStyle()->success('No Metadata Classes to process.');

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $
return 0;
}

$ui->caution('This operation should not be executed in a production environment!');
$notificationUi = $ui->getErrorStyle();

$ui->text('Creating database schema...');
$ui->newLine();
$notificationUi->caution('This operation should not be executed in a production environment!');

$notificationUi->text('Creating database schema...');
$notificationUi->newLine();

$schemaTool->createSchema($metadatas);

$ui->success('Database schema created successfully!');
$notificationUi->success('Database schema created successfully!');

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,24 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $
return 0;
}

$notificationUi = $ui->getErrorStyle();

if ($force) {
$ui->text('Dropping database schema...');
$ui->newLine();
$notificationUi->text('Dropping database schema...');
$notificationUi->newLine();

if ($isFullDatabaseDrop) {
$schemaTool->dropDatabase();
} else {
$schemaTool->dropSchema($metadatas);
}

$ui->success('Database schema dropped successfully!');
$notificationUi->success('Database schema dropped successfully!');

return 0;
}

$ui->caution('This operation should not be executed in a production environment!');
$notificationUi->caution('This operation should not be executed in a production environment!');

if ($isFullDatabaseDrop) {
$sqls = $schemaTool->getDropDatabaseSQL();
Expand All @@ -91,12 +93,12 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $
}

if (empty($sqls)) {
$ui->success('Nothing to drop. The database is empty!');
$notificationUi->success('Nothing to drop. The database is empty!');

return 0;
}

$ui->text(
$notificationUi->text(
[
sprintf('The Schema-Tool would execute <info>"%s"</info> queries to update the database.', count($sqls)),
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $

$sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);

$notificationUi = $ui->getErrorStyle();

if (empty($sqls)) {
$ui->success('Nothing to update - your database is already in sync with the current entity metadata.');
$notificationUi->success('Nothing to update - your database is already in sync with the current entity metadata.');

return 0;
}
Expand All @@ -95,25 +97,25 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $

if ($force) {
if ($dumpSql) {
$ui->newLine();
$notificationUi->newLine();
}

$ui->text('Updating database schema...');
$ui->newLine();
$notificationUi->text('Updating database schema...');
$notificationUi->newLine();

$schemaTool->updateSchema($metadatas, $saveMode);

$pluralization = count($sqls) === 1 ? 'query was' : 'queries were';

$ui->text(sprintf(' <info>%s</info> %s executed', count($sqls), $pluralization));
$ui->success('Database schema updated successfully!');
$notificationUi->text(sprintf(' <info>%s</info> %s executed', count($sqls), $pluralization));
$notificationUi->success('Database schema updated successfully!');
}

if ($dumpSql || $force) {
return 0;
}

$ui->caution(
$notificationUi->caution(
[
'This operation should not be executed in a production environment!',
'',
Expand All @@ -122,7 +124,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $
]
);

$ui->text(
$notificationUi->text(
[
sprintf('The Schema-Tool would execute <info>"%s"</info> queries to update the database.', count($sqls)),
'',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
$ui = (new SymfonyStyle($input, $output))->getErrorStyle();

$em = $this->getEntityManager($input);
$validator = new SchemaValidator($em);
Expand Down