Skip to content

Commit

Permalink
feat(bus): add disable transaction contract when dispatch command
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckbon3 committed Oct 14, 2021
1 parent 3a351f8 commit 10bff60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Component/Bus/Contract/DisableTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Pandawa\Component\Bus\Contract;

/**
* @author Iqbal Maulana <iq.bluejack@gmail.com>
*/
interface DisableTransaction
{
}
5 changes: 3 additions & 2 deletions src/Component/Bus/Pipe/DatabaseTransactionPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

namespace Pandawa\Component\Bus\Pipe;

use Illuminate\Support\Facades\DB;
use Pandawa\Component\Bus\Contract\DisableTransaction;
use Pandawa\Component\Message\AbstractCommand;
use Pandawa\Component\Message\AbstractMessage;
use DB;

/**
* @author Iqbal Maulana <iq.bluejack@gmail.com>
Expand All @@ -33,7 +34,7 @@ final class DatabaseTransactionPipe
*/
public function handle($message, $next)
{
if ($message instanceof AbstractCommand) {
if ($message instanceof AbstractCommand && !$message instanceof DisableTransaction) {
return DB::transaction(
function () use ($message, $next) {
return $next($message);
Expand Down

0 comments on commit 10bff60

Please sign in to comment.