Skip to content

Commit

Permalink
Rename to TransactionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers committed Feb 26, 2019
1 parent 2989cd1 commit 13374da
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
9 changes: 6 additions & 3 deletions config/excel.php
Expand Up @@ -137,17 +137,20 @@

/*
|--------------------------------------------------------------------------
| Transaction Driver
| Transaction Handler
|--------------------------------------------------------------------------
|
| By default the import is wrapped in a transaction. This is useful
| for when an import may fail and you want to retry it. With the
| transactions, the previous import gets rolled-back.
|
| Drivers: db|null
| You can disable the transaction handler by setting this to null.
| Or you can choose a custom made transaction handler here.
|
| Supported handlers: null|db
|
*/
'driver' => 'db',
'handle' => 'db',
],

'temporary_files' => [
Expand Down
3 changes: 2 additions & 1 deletion src/ExcelServiceProvider.php
Expand Up @@ -12,6 +12,7 @@
use Maatwebsite\Excel\Mixins\DownloadCollection;
use Maatwebsite\Excel\Files\TemporaryFileFactory;
use Laravel\Lumen\Application as LumenApplication;
use Maatwebsite\Excel\Transactions\TransactionHandler;
use Maatwebsite\Excel\Transactions\TransactionManager;

class ExcelServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -46,7 +47,7 @@ public function register()
return new TransactionManager($this->app);
});

$this->app->bind(Transaction::class, function () {
$this->app->bind(TransactionHandler::class, function () {
return $this->app->make(TransactionManager::class)->driver();
});

Expand Down
6 changes: 3 additions & 3 deletions src/Jobs/ReadChunk.php
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use Maatwebsite\Excel\Filters\ChunkReadFilter;
use Maatwebsite\Excel\Transactions\Transaction;
use Maatwebsite\Excel\Transactions\TransactionHandler;
use Maatwebsite\Excel\Imports\HeadingRowExtractor;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;

Expand Down Expand Up @@ -66,12 +66,12 @@ public function __construct(IReader $reader, TemporaryFile $temporaryFile, strin
}

/**
* @param Transaction $transaction
* @param TransactionHandler $transaction
*
* @throws \Maatwebsite\Excel\Exceptions\SheetNotFoundException
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function handle(Transaction $transaction)
public function handle(TransactionHandler $transaction)
{
if ($this->sheetImport instanceof WithCustomValueBinder) {
Cell::setValueBinder($this->sheetImport);
Expand Down
7 changes: 4 additions & 3 deletions src/Reader.php
Expand Up @@ -4,6 +4,7 @@

use InvalidArgumentException;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Transactions\TransactionHandler;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use Maatwebsite\Excel\Events\AfterImport;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
Expand Down Expand Up @@ -50,15 +51,15 @@ class Reader
protected $temporaryFileFactory;

/**
* @var Transaction
* @var TransactionHandler
*/
protected $transaction;

/**
* @param TemporaryFileFactory $temporaryFileFactory
* @param Transaction $transaction
* @param TransactionHandler $transaction
*/
public function __construct(TemporaryFileFactory $temporaryFileFactory, Transaction $transaction)
public function __construct(TemporaryFileFactory $temporaryFileFactory, TransactionHandler $transaction)
{
$this->setDefaultValueBinder();

Expand Down
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\ConnectionInterface;

class DbTransaction implements Transaction
class DbTransactionHandler implements TransactionHandler
{
/**
* @var ConnectionInterface
Expand Down
Expand Up @@ -2,7 +2,7 @@

namespace Maatwebsite\Excel\Transactions;

class NullTransaction implements Transaction
class NullTransactionHandler implements TransactionHandler
{
/**
* @param callable $callback
Expand Down
Expand Up @@ -2,7 +2,7 @@

namespace Maatwebsite\Excel\Transactions;

interface Transaction
interface TransactionHandler
{
/**
* @param callable $callback
Expand Down
8 changes: 4 additions & 4 deletions src/Transactions/TransactionManager.php
Expand Up @@ -15,19 +15,19 @@ public function getDefaultDriver()
}

/**
* @return NullTransaction
* @return NullTransactionHandler
*/
public function createNullDriver()
{
return new NullTransaction();
return new NullTransactionHandler();
}

/**
* @return DbTransaction
* @return DbTransactionHandler
*/
public function createDbDriver()
{
return new DbTransaction(
return new DbTransactionHandler(
$this->app->get('db.connection')
);
}
Expand Down

0 comments on commit 13374da

Please sign in to comment.