| 1 | <?php |
||
| 12 | class TransactionMiddleware implements Middleware |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var EntityManagerInterface |
||
| 16 | */ |
||
| 17 | private $entityManager; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param EntityManagerInterface $entityManager |
||
| 21 | */ |
||
| 22 | public function __construct(EntityManagerInterface $entityManager) |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Executes the given command and optionally returns a value |
||
| 29 | * |
||
| 30 | * @param object $command |
||
| 31 | * @param callable $next |
||
| 32 | * @return mixed |
||
| 33 | * @throws Throwable |
||
| 34 | * @throws Exception |
||
| 35 | */ |
||
| 36 | public function execute($command, callable $next) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Rollback the current transaction and close the entity manager when possible. |
||
| 60 | */ |
||
| 61 | protected function rollbackTransaction() |
||
| 70 | } |
||
| 71 |