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 AbstractLogger instead of Closure in LoadDataFixturesDoctrineODMCommand. #865

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"require-dev": {
"doctrine/coding-standard": "^11.0",
"doctrine/data-fixtures": "^1.7",
"doctrine/data-fixtures": "^1.8 || ^2.0",
mickverm marked this conversation as resolved.
Show resolved Hide resolved
"phpunit/phpunit": "^9.5.5",
"psalm/plugin-symfony": "^5.0",
"symfony/browser-kit": "^6.4 || ^7.0",
Expand All @@ -53,7 +53,7 @@
"vimeo/psalm": "^5.25"
},
"conflict": {
"doctrine/data-fixtures": "<1.3"
"doctrine/data-fixtures": "<1.8"
},
"suggest": {
"doctrine/data-fixtures": "Load data fixtures"
Expand Down
10 changes: 8 additions & 2 deletions src/Command/LoadDataFixturesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor;
use Doctrine\Common\DataFixtures\Purger\MongoDBPurger;
use Psr\Log\AbstractLogger;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -83,8 +84,13 @@

$purger = new MongoDBPurger($dm);
$executor = new MongoDBExecutor($dm, $purger);
$executor->setLogger(static function ($message) use ($output): void {
$output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message));
$executor->setLogger(new class($output) extends AbstractLogger {

Check failure on line 87 in src/Command/LoadDataFixturesDoctrineODMCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.3)

Expected 1 space after class keyword; 0 found
public function __construct(private readonly OutputInterface $output) {}

Check failure on line 88 in src/Command/LoadDataFixturesDoctrineODMCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.3)

Opening brace should be on a new line

Check failure on line 88 in src/Command/LoadDataFixturesDoctrineODMCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.3)

Closing brace must be on a line by itself

public function log(mixed $level, string|\Stringable $message, array $context = []): void

Check failure on line 90 in src/Command/LoadDataFixturesDoctrineODMCommand.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.3)

Class \Stringable should not be referenced via a fully qualified name, but via a use statement.
{
$this->output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message));
}
});
$executor->execute($fixtures, $input->getOption('append'));

Expand Down
Loading