Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise Before and After import events + garbage collect after import i…
…s finished (#1944)
- Loading branch information
1 parent
8576af6
commit b26dcc6
Showing
4 changed files
with
275 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Maatwebsite\Excel\Jobs; | ||
|
||
use Maatwebsite\Excel\Reader; | ||
use Illuminate\Bus\Queueable; | ||
use Maatwebsite\Excel\Concerns\WithEvents; | ||
|
||
class AfterImportJob | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* @var WithEvents | ||
*/ | ||
private $import; | ||
|
||
/** | ||
* @var Reader | ||
*/ | ||
private $reader; | ||
|
||
/** | ||
* @param object $import | ||
* @param Reader $reader | ||
*/ | ||
public function __construct($import, Reader $reader) | ||
{ | ||
$this->import = $import; | ||
$this->reader = $reader; | ||
} | ||
|
||
public function handle() | ||
{ | ||
if ($this->import instanceof WithEvents) { | ||
if (null === $this->reader->getDelegate()) { | ||
$this->reader->readSpreadsheet(); | ||
} | ||
|
||
$this->reader->registerListeners($this->import->registerEvents()); | ||
} | ||
|
||
$this->reader->afterImport($this->import); | ||
} | ||
} |
Oops, something went wrong.