|
12 | 12 | use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
13 | 13 | use Doctrine\ORM\EntityManagerInterface;
|
14 | 14 | use Doctrine\Persistence\ManagerRegistry;
|
| 15 | +use Psr\Log\AbstractLogger; |
15 | 16 | use Symfony\Component\Console\Input\InputInterface;
|
16 | 17 | use Symfony\Component\Console\Input\InputOption;
|
17 | 18 | use Symfony\Component\Console\Output\OutputInterface;
|
@@ -134,9 +135,27 @@ private function doExecute(InputInterface $input, OutputInterface $output): int
|
134 | 135 | $input->getOption('purge-with-truncate'),
|
135 | 136 | );
|
136 | 137 | $executor = new ORMExecutor($em, $purger);
|
137 |
| - $executor->setLogger(static function ($message) use ($ui): void { |
138 |
| - $ui->text(sprintf(' <comment>></comment> <info>%s</info>', $message)); |
| 138 | + $executor->setLogger(new class ($ui) extends AbstractLogger { |
| 139 | + private SymfonyStyle $ui; |
| 140 | + |
| 141 | + public function __construct(SymfonyStyle $ui) |
| 142 | + { |
| 143 | + $this->ui = $ui; |
| 144 | + } |
| 145 | + |
| 146 | + /** {@inheritDoc} */ |
| 147 | + public function log($level, $message, array $context = []): void |
| 148 | + { |
| 149 | + $this->ui->text(sprintf(' <comment>></comment> <info>%s</info>', $message)); |
| 150 | + } |
| 151 | + |
| 152 | + /** @deprecated to be removed when dropping support for doctrine/data-fixtures <1.8 */ |
| 153 | + public function __invoke(string $message): void |
| 154 | + { |
| 155 | + $this->log(0, $message); |
| 156 | + } |
139 | 157 | });
|
| 158 | + |
140 | 159 | $executor->execute($fixtures, $input->getOption('append'));
|
141 | 160 |
|
142 | 161 | return 0;
|
|
0 commit comments