| 1 | <?php |
||
| 16 | class TransactionMiddleware implements TransactionInterface, MiddlewareInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var TransactionInterface |
||
| 20 | */ |
||
| 21 | private $transaction; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var bool |
||
| 25 | */ |
||
| 26 | private $enabled = true; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param \Spiral\ORM\TransactionInterface $transaction |
||
| 30 | * @param bool $enabled |
||
| 31 | */ |
||
| 32 | public function __construct(TransactionInterface $transaction, bool $enabled = true) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
| 40 | * @param \Psr\Http\Message\ResponseInterface $response |
||
| 41 | * @param callable $next |
||
| 42 | * |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | public function __invoke(Request $request, Response $response, callable $next) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param \Spiral\ORM\CommandInterface $command |
||
| 59 | */ |
||
| 60 | public function addCommand(CommandInterface $command) |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Forwarded to outer tranasction. |
||
| 67 | */ |
||
| 68 | public function run() |
||
| 72 | } |