Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ApieUpdateIdfCommand | |
16.67% |
1 / 6 |
|
50.00% |
1 / 2 |
19.47 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Apie\DoctrineEntityDatalayer\Commands; |
| 4 | |
| 5 | use Apie\DoctrineEntityDatalayer\EntityReindexer; |
| 6 | use Apie\DoctrineEntityDatalayer\OrmBuilder; |
| 7 | use Apie\StorageMetadataBuilder\Interfaces\HasIndexInterface; |
| 8 | use Symfony\Component\Console\Command\Command; |
| 9 | use Symfony\Component\Console\Input\InputInterface; |
| 10 | use Symfony\Component\Console\Output\OutputInterface; |
| 11 | |
| 12 | class ApieUpdateIdfCommand extends Command |
| 13 | { |
| 14 | public function __construct( |
| 15 | private readonly EntityReindexer $entityReindexer, |
| 16 | private readonly OrmBuilder $ormBuilder |
| 17 | ) { |
| 18 | parent::__construct('apie:update-idf'); |
| 19 | } |
| 20 | |
| 21 | protected function execute(InputInterface $input, OutputInterface $output): int |
| 22 | { |
| 23 | foreach ($this->ormBuilder->createEntityManager()->getMetadataFactory()->getAllMetadata() as $metadata) { |
| 24 | if ($metadata->reflClass && in_array(HasIndexInterface::class, $metadata->reflClass->getInterfaceNames())) { |
| 25 | $output->writeln($metadata->reflClass->getMethod('getClassReference')->invoke(null)->getShortName()); |
| 26 | $this->entityReindexer->recalculateIdfForAll($metadata->reflClass); |
| 27 | } |
| 28 | } |
| 29 | return Command::SUCCESS; |
| 30 | } |
| 31 | } |