ImportWithEvents.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Maatwebsite\Excel\Tests\Data\Stubs;
  3. use Maatwebsite\Excel\Concerns\Importable;
  4. use Maatwebsite\Excel\Concerns\WithEvents;
  5. use Maatwebsite\Excel\Events\AfterImport;
  6. use Maatwebsite\Excel\Events\AfterSheet;
  7. use Maatwebsite\Excel\Events\BeforeImport;
  8. use Maatwebsite\Excel\Events\BeforeSheet;
  9. class ImportWithEvents implements WithEvents
  10. {
  11. use Importable;
  12. /**
  13. * @var callable
  14. */
  15. public $beforeImport;
  16. /**
  17. * @var callable
  18. */
  19. public $afterImport;
  20. /**
  21. * @var callable
  22. */
  23. public $beforeSheet;
  24. /**
  25. * @var callable
  26. */
  27. public $afterSheet;
  28. /**
  29. * @return array
  30. */
  31. public function registerEvents(): array
  32. {
  33. return [
  34. BeforeImport::class => $this->beforeImport ?? function () {
  35. },
  36. AfterImport::class => $this->afterImport ?? function () {
  37. },
  38. BeforeSheet::class => $this->beforeSheet ?? function () {
  39. },
  40. AfterSheet::class => $this->afterSheet ?? function () {
  41. },
  42. ];
  43. }
  44. }