8
8
9
9
namespace MageOS \Indexer \Model ;
10
10
11
- use MageOS \Indexer \Api \IndexRecordMutableData ;
12
-
11
+ use MageOS \Indexer \Api \IndexRecordMutable ;
13
12
use Traversable ;
14
13
15
- class ArrayIndexRecordData implements \IteratorAggregate, IndexRecordMutableData
14
+ class ArrayIndexRecord implements IndexRecordMutable
16
15
{
17
16
public function __construct (
18
17
private array $ data = [],
19
18
private array $ scopeData = []
20
- ) {
21
-
22
- }
23
-
24
- public function getIterator (): Traversable
19
+ )
25
20
{
26
- foreach ($ this ->data as $ entityId => $ item ) {
27
- yield $ entityId ;
28
- }
21
+
29
22
}
30
23
31
24
public function reset (): void
@@ -34,22 +27,22 @@ public function reset(): void
34
27
$ this ->scopeData = [];
35
28
}
36
29
37
- public function setValue (int $ entityId , array $ data ): void
30
+ public function set (int $ entityId , array $ data ): void
38
31
{
39
32
$ this ->data [$ entityId ] = $ data ;
40
33
}
41
34
42
- public function addValue (int $ entityId , string $ field , mixed $ value ): void
35
+ public function add (int $ entityId , string $ field , mixed $ value ): void
43
36
{
44
37
$ this ->data [$ entityId ][$ field ] = $ value ;
45
38
}
46
39
47
- public function extendValue (int $ entityId , string $ field , string $ key , mixed $ value ): void
40
+ public function append (int $ entityId , string $ field , string $ key , mixed $ value ): void
48
41
{
49
42
$ this ->data [$ entityId ][$ field ][$ key ] = $ value ;
50
43
}
51
44
52
- public function addScopeValue (int $ entityId , int $ storeId , string $ field , mixed $ value ): void
45
+ public function addInScope (int $ entityId , int $ storeId , string $ field , mixed $ value ): void
53
46
{
54
47
if (!isset ($ this ->data [$ entityId ])) {
55
48
return ;
@@ -58,15 +51,22 @@ public function addScopeValue(int $entityId, int $storeId, string $field, mixed
58
51
$ this ->scopeData [$ entityId ][$ storeId ][$ field ] = $ value ;
59
52
}
60
53
61
- public function getScopeValue (int $ entityId , int $ scopeId , string $ field ): mixed
54
+ public function getInScope (int $ entityId , int $ scopeId , string $ field ): mixed
62
55
{
63
56
return $ this ->scopeData [$ entityId ][$ scopeId ][$ field ]
64
57
?? $ this ->scopeData [$ entityId ][0 ][$ field ]
65
58
?? null ;
66
59
}
67
60
68
- public function getValue (int $ entityId , string $ field ): mixed
61
+ public function get (int $ entityId , string $ field ): mixed
69
62
{
70
63
return $ this ->data [$ entityId ][$ field ] ?? null ;
71
64
}
65
+
66
+ public function listEntityIds (): iterable
67
+ {
68
+ foreach ($ this ->data as $ entityId => $ item ) {
69
+ yield $ entityId ;
70
+ }
71
+ }
72
72
}
0 commit comments