Lines
n/a
0 / 0
Functions and Methods
n/a
0 / 0
Classes and Traits
n/a
0 / 0
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| TransactionMiddleware | n/a | 0 / 0 | n/a | 0 / 0 | 2 | n/a | 0 / 0 | |||
| __invoke | n/a | 0 / 0 | n/a | 0 / 0 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\Helper; | |
| 4 | ||
| 5 | use BO\Zmsbackend\Connection\Select; | |
| 6 | use Psr\Http\Message\ServerRequestInterface; | |
| 7 | use Psr\Http\Server\RequestHandlerInterface; | |
| 8 | ||
| 9 | class TransactionMiddleware | |
| 10 | { | |
| 11 | /** | |
| 12 | * @codeCoverageIgnore | |
| 13 | * | |
| 14 | */ | |
| 15 | public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $next) | |
| 16 | { | |
| 17 | Select::setTransaction(); | |
| 18 | try { | |
| 19 | $response = $next->handle($request); | |
| 20 | } catch (\Exception $exception) { | |
| 21 | Select::writeRollback(); | |
| 22 | throw $exception; | |
| 23 | } | |
| 24 | Select::writeCommit(); | |
| 25 | ||
| 26 | return $response; | |
| 27 | } | |
| 28 | } |