1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backend\Modules\MediaLibraryImporter\Component; |
4
|
|
|
|
5
|
|
|
use Backend\Modules\MediaLibraryImporter\Domain\MediaItemImport\MediaItemImport; |
6
|
|
|
use Backend\Modules\MediaLibraryImporter\Domain\MediaItemImport\Status; |
7
|
|
|
|
8
|
|
|
class ImportResults |
9
|
|
|
{ |
10
|
|
|
/** @var int */ |
11
|
|
|
protected $numberOfErrorImports = 0; |
12
|
|
|
|
13
|
|
|
/** @var int */ |
14
|
|
|
protected $numberOfImportedItems = 0; |
15
|
|
|
|
16
|
|
|
/** @var int */ |
17
|
|
|
protected $numberOfQueuedItems = 0; |
18
|
|
|
|
19
|
|
|
/** @var int */ |
20
|
|
|
protected $numberOfSuccessfulImports = 0; |
21
|
|
|
|
22
|
|
|
public function __construct(int $numberOfQueuedItems) |
23
|
|
|
{ |
24
|
|
|
$this->numberOfQueuedItems = $numberOfQueuedItems; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function bumpAfterMediaItemImport(MediaItemImport $mediaItemImport): void |
28
|
|
|
{ |
29
|
|
|
switch ($mediaItemImport->getStatus()) { |
30
|
|
|
case Status::imported(): |
31
|
|
|
$this->bumpNumberOfImportedItems(); |
32
|
|
|
$this->bumpNumberOfSuccessfulImports(); |
33
|
|
|
break; |
34
|
|
|
case Status::existing(): |
35
|
|
|
$this->bumpNumberOfSuccessfulImports(); |
36
|
|
|
break; |
37
|
|
|
case Status::error(): |
38
|
|
|
$this->bumpNumberOfErrorImports(); |
39
|
|
|
break; |
40
|
|
|
default: |
41
|
|
|
// do nothing |
42
|
|
|
break; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function bumpNumberOfErrorImports(): void |
47
|
|
|
{ |
48
|
|
|
$this->numberOfErrorImports ++; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function bumpNumberOfImportedItems(): void |
52
|
|
|
{ |
53
|
|
|
$this->numberOfImportedItems ++; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function bumpNumberOfSuccessfulImports(): void |
57
|
|
|
{ |
58
|
|
|
$this->numberOfSuccessfulImports ++; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getNumberOfErrorImports(): int |
62
|
|
|
{ |
63
|
|
|
return $this->numberOfErrorImports; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getNumberOfImportedItems(): int |
67
|
|
|
{ |
68
|
|
|
return $this->numberOfImportedItems; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getNumberOfQueuedItems(): int |
72
|
|
|
{ |
73
|
|
|
return $this->numberOfQueuedItems; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getNumberOfSuccessfulImports(): int |
77
|
|
|
{ |
78
|
|
|
return $this->numberOfSuccessfulImports; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|