Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reintroduce DoctrineTransactionalSession persa durante il refact…
…oring dei moduli
- Loading branch information
Showing
13 changed files
with
81 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
./dc coding-standard-fix "$@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Matiux/DDDStarterPack/Service/Infrastructure/Doctrine/DoctrineTransactionalSession.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DDDStarterPack\Service\Infrastructure\Doctrine; | ||
|
||
use DDDStarterPack\Exception\Application\TransactionFailedException; | ||
use DDDStarterPack\Service\Application\TransactionalSession; | ||
use Doctrine\ORM\EntityManager; | ||
use Throwable; | ||
|
||
/** | ||
* @template O | ||
* | ||
* @implements TransactionalSession<O> | ||
*/ | ||
class DoctrineTransactionalSession implements TransactionalSession | ||
{ | ||
public function __construct(private EntityManager $entityManager) | ||
{ | ||
} | ||
|
||
/** | ||
* @param callable $operation | ||
* | ||
* @throws TransactionFailedException | ||
* | ||
* @return O | ||
*/ | ||
public function executeAtomically(callable $operation) | ||
{ | ||
try { | ||
/** @var O $reponse */ | ||
$reponse = $this->entityManager->wrapInTransaction($operation); | ||
|
||
return $reponse; | ||
} catch (Throwable $t) { | ||
throw new TransactionFailedException(sprintf('Transaction failed: %s', $t->getMessage()), (int) $t->getCode(), $t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters