@@ -134,25 +134,33 @@ protected function saveToFile(string $data, string $file):void{
134
134
/**
135
135
* collects the modules per QRMatrix::M_* type and runs a $transform functio on each module and
136
136
* returns an array with the transformed modules
137
+ *
138
+ * The transform callback is called with the following parameters:
139
+ *
140
+ * $x - current column
141
+ * $y - current row
142
+ * $M_TYPE - field value
143
+ * $M_TYPE_LAYER - (possibly modified) field value that acts as layer id
137
144
*/
138
145
protected function collectModules (Closure $ transform ):array {
139
146
$ paths = [];
140
147
141
148
// collect the modules for each type
142
149
foreach ($ this ->matrix ->matrix () as $ y => $ row ){
143
150
foreach ($ row as $ x => $ M_TYPE ){
151
+ $ M_TYPE_LAYER = $ M_TYPE ;
144
152
145
153
if ($ this ->options ->connectPaths && $ this ->matrix ->checkTypeNotIn ($ x , $ y , $ this ->options ->excludeFromConnect )){
146
- // to connect paths we'll redeclare the $M_TYPE to data only
147
- $ M_TYPE = QRMatrix::M_DATA ;
154
+ // to connect paths we'll redeclare the $M_TYPE_LAYER to data only
155
+ $ M_TYPE_LAYER = QRMatrix::M_DATA ;
148
156
149
157
if ($ this ->matrix ->check ($ x , $ y )){
150
- $ M_TYPE |= QRMatrix::IS_DARK ;
158
+ $ M_TYPE_LAYER |= QRMatrix::IS_DARK ;
151
159
}
152
160
}
153
161
154
162
// collect the modules per $M_TYPE
155
- $ paths [$ M_TYPE ][] = $ transform ($ x , $ y , $ M_TYPE );
163
+ $ paths [$ M_TYPE_LAYER ][] = $ transform ($ x , $ y , $ M_TYPE , $ M_TYPE_LAYER );
156
164
}
157
165
}
158
166
0 commit comments