@@ -26,6 +26,11 @@ class ProcessingErrorAggregator implements ProcessingErrorAggregatorInterface
26
26
*/
27
27
protected $ items = [];
28
28
29
+ /**
30
+ * @var ProcessingError[]
31
+ */
32
+ private $ itemsByRowColumnAndCode = [];
33
+
29
34
/**
30
35
* @var int[]
31
36
*/
@@ -87,13 +92,13 @@ public function addError(
87
92
$ this ->processInvalidRow ($ rowNumber );
88
93
}
89
94
$ errorMessage = $ this ->getErrorMessage ($ errorCode , $ errorMessage , $ columnName );
90
-
91
95
/** @var ProcessingError $newError */
92
96
$ newError = $ this ->errorFactory ->create ();
93
97
$ newError ->init ($ errorCode , $ errorLevel , $ rowNumber , $ columnName , $ errorMessage , $ errorDescription );
94
98
$ this ->items ['rows ' ][$ rowNumber ][] = $ newError ;
95
99
$ this ->items ['codes ' ][$ errorCode ][] = $ newError ;
96
100
$ this ->items ['messages ' ][$ errorMessage ][] = $ newError ;
101
+ $ this ->itemsByRowColumnAndCode [$ rowNumber ][$ columnName ][$ errorCode ] = $ newError ;
97
102
return $ this ;
98
103
}
99
104
@@ -356,7 +361,7 @@ public function clear()
356
361
$ this ->errorStatistics = [];
357
362
$ this ->invalidRows = [];
358
363
$ this ->skippedRows = [];
359
-
364
+ $ this -> itemsByRowColumnAndCode = [];
360
365
return $ this ;
361
366
}
362
367
@@ -370,13 +375,7 @@ public function clear()
370
375
*/
371
376
protected function isErrorAlreadyAdded ($ rowNum , $ errorCode , $ columnName = null )
372
377
{
373
- $ errors = $ this ->getErrorsByCode ([$ errorCode ]);
374
- foreach ($ errors as $ error ) {
375
- if ($ rowNum == $ error ->getRowNumber () && $ columnName == $ error ->getColumnName ()) {
376
- return true ;
377
- }
378
- }
379
- return false ;
378
+ return isset ($ this ->itemsByRowColumnAndCode [$ rowNum ][$ columnName ][$ errorCode ]);
380
379
}
381
380
382
381
/**
0 commit comments