Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| IdGeneratorLfdnr | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| generateId | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Satag\AmicronEntityBundle\Doctrine; |
| 6 | |
| 7 | use Doctrine\DBAL\Exception; |
| 8 | use Doctrine\ORM\EntityManagerInterface; |
| 9 | use Doctrine\ORM\Id\AbstractIdGenerator; |
| 10 | |
| 11 | /** |
| 12 | * Generic Firebird sequence ID generator using GEN_LFDNR. |
| 13 | * Used for entities that only require a sequential lfdnr (no separate number sequence). |
| 14 | */ |
| 15 | class IdGeneratorLfdnr extends AbstractIdGenerator |
| 16 | { |
| 17 | /** |
| 18 | * @throws Exception |
| 19 | */ |
| 20 | public function generateId(EntityManagerInterface $em, ?object $entity): mixed |
| 21 | { |
| 22 | $dbConnection = $em->getConnection(); |
| 23 | $sequenceNextValSQL = $dbConnection->getDatabasePlatform()->getSequenceNextValSQL('GEN_LFDNR'); |
| 24 | |
| 25 | return $dbConnection->fetchOne($sequenceNextValSQL); |
| 26 | } |
| 27 | } |