use entity manager to resolve class table name
This commit is contained in:
parent
5465b39332
commit
8fa1e1089e
1 changed files with 3 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Sequence\Service;
|
namespace DigiComp\Sequence\Service;
|
||||||
|
|
||||||
|
use DigiComp\Sequence\Domain\Model\Insert;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
@ -68,7 +69,7 @@ class SequenceGenerator
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
try {
|
try {
|
||||||
$em->getConnection()->insert(
|
$em->getConnection()->insert(
|
||||||
'digicomp_sequence_domain_model_insert',
|
$em->getClassMetadata(Insert::class)->getTableName(),
|
||||||
['number' => $count, 'type' => $type]
|
['number' => $count, 'type' => $type]
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,7 +112,7 @@ class SequenceGenerator
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
return $em->getConnection()->executeQuery(
|
return $em->getConnection()->executeQuery(
|
||||||
'SELECT MAX(number) AS count FROM digicomp_sequence_domain_model_insert WHERE type=:type',
|
'SELECT MAX(number) AS count FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type=:type',
|
||||||
['type' => $this->inferTypeFromSource($type)]
|
['type' => $this->inferTypeFromSource($type)]
|
||||||
)->fetchAll()[0]['count'];
|
)->fetchAll()[0]['count'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue