Skip to content

Commit

Permalink
PD-13 Inject EM into Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
martineiber committed Jan 31, 2024
1 parent c613abc commit fe4a26e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion config/services/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ services:
autoconfigure: true
public: false

Pimcore\Bundle\GenericDataIndexBundle\Repository\IndexQueueRepository: ~
Pimcore\Bundle\GenericDataIndexBundle\Repository\IndexQueueRepository:
arguments:
- "@doctrine.orm.pimcore_generic_data_index_entity_manager"

8 changes: 3 additions & 5 deletions src/Repository/IndexQueueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace Pimcore\Bundle\GenericDataIndexBundle\Repository;

use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;

Check notice on line 17 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityManager' is never used

Check notice on line 17 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityManager' is never used

Check notice on line 17 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityManager' is never used
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;

Check notice on line 19 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityRepository' is never used

Check notice on line 19 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityRepository' is never used

Check notice on line 19 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unused import

Import 'Doctrine\\ORM\\EntityRepository' is never used
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\QueryBuilder;
Expand All @@ -30,15 +32,12 @@ final class IndexQueueRepository
{
use LoggerAwareTrait;

private readonly ObjectManager $entityManager;

public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly TimeServiceInterface $timeService,
private readonly Connection $connection,
private readonly DenormalizerInterface $denormalizer,
ManagerRegistry $managerRegistry,
) {
$this->entityManager = $managerRegistry->getManager('pimcore_generic_data_index');
}

public function dispatchableItemExists(): bool
Expand Down Expand Up @@ -166,7 +165,6 @@ private function dispatchItems(int $limit): int

private function createQueryBuilder(string $alias): QueryBuilder
{
/** @var EntityRepository $repository */
$repository = $this->entityManager->getRepository(IndexQueue::class);

Check warning on line 168 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

One-time use variables

\[EA\] Variable $repository is redundant.

Check warning on line 168 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

One-time use variables

\[EA\] Variable $repository is redundant.

Check warning on line 168 in src/Repository/IndexQueueRepository.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

One-time use variables

\[EA\] Variable $repository is redundant.

return $repository->createQueryBuilder($alias);
Expand Down

0 comments on commit fe4a26e

Please sign in to comment.