@@ -32,10 +32,28 @@ final class CwaCollectorData implements ResetInterface
3232 private ?string $ resolvedRouteIri = null ;
3333 private bool $ pageDataFound = false ;
3434
35- // --- Mercure ---
35+ // --- Mercure publications ---
3636 /** @var list<string> */
3737 private array $ publishedTopics = [];
3838
39+ // --- Publishable ORM queries ---
40+ /** @var list<array{class: string, mode: string, queryType: string}> */
41+ private array $ publishableQueries = [];
42+
43+ // --- PageDataProperty resolutions ---
44+ /** @var list<array{property: string, resolvedClass: string|null, skipReason: string|null}> */
45+ private array $ pageDataResolutions = [];
46+
47+ // --- Write invalidation fan-out ---
48+ /** @var array{created: int, updated: int, deleted: int} */
49+ private array $ invalidationCounts = ['created ' => 0 , 'updated ' => 0 , 'deleted ' => 0 ];
50+ /** @var list<string> */
51+ private array $ cachePurgedIris = [];
52+
53+ // --- Private Mercure upgrades ---
54+ /** @var list<array{topics: list<string>, resourceClass: string}> */
55+ private array $ mercurePrivateUpgrades = [];
56+
3957 // -----------------------------------------------------------------------
4058 // JWT
4159 // -----------------------------------------------------------------------
@@ -107,7 +125,7 @@ public function isPageDataFound(): bool
107125 }
108126
109127 // -----------------------------------------------------------------------
110- // Mercure
128+ // Mercure publications
111129 // -----------------------------------------------------------------------
112130
113131 public function recordMercurePublication (string $ topic ): void
@@ -126,6 +144,106 @@ public function getPublishedTopicsCount(): int
126144 return \count ($ this ->publishedTopics );
127145 }
128146
147+ // -----------------------------------------------------------------------
148+ // Publishable ORM queries
149+ // -----------------------------------------------------------------------
150+
151+ public function recordPublishableQuery (string $ class , string $ mode , string $ queryType ): void
152+ {
153+ $ this ->publishableQueries [] = ['class ' => $ class , 'mode ' => $ mode , 'queryType ' => $ queryType ];
154+ }
155+
156+ /** @return list<array{class: string, mode: string, queryType: string}> */
157+ public function getPublishableQueries (): array
158+ {
159+ return $ this ->publishableQueries ;
160+ }
161+
162+ public function getPublishableQueryCount (): int
163+ {
164+ return \count ($ this ->publishableQueries );
165+ }
166+
167+ // -----------------------------------------------------------------------
168+ // PageDataProperty resolutions
169+ // -----------------------------------------------------------------------
170+
171+ public function recordPageDataResolution (string $ property , ?string $ resolvedClass , ?string $ skipReason ): void
172+ {
173+ $ this ->pageDataResolutions [] = ['property ' => $ property , 'resolvedClass ' => $ resolvedClass , 'skipReason ' => $ skipReason ];
174+ }
175+
176+ /** @return list<array{property: string, resolvedClass: string|null, skipReason: string|null}> */
177+ public function getPageDataResolutions (): array
178+ {
179+ return $ this ->pageDataResolutions ;
180+ }
181+
182+ public function getPageDataResolutionCount (): int
183+ {
184+ return \count ($ this ->pageDataResolutions );
185+ }
186+
187+ // -----------------------------------------------------------------------
188+ // Write invalidation fan-out
189+ // -----------------------------------------------------------------------
190+
191+ public function recordInvalidationCount (string $ type ): void
192+ {
193+ if (isset ($ this ->invalidationCounts [$ type ])) {
194+ ++$ this ->invalidationCounts [$ type ];
195+ }
196+ }
197+
198+ /** @return array{created: int, updated: int, deleted: int} */
199+ public function getInvalidationCounts (): array
200+ {
201+ return $ this ->invalidationCounts ;
202+ }
203+
204+ public function getTotalInvalidated (): int
205+ {
206+ return array_sum ($ this ->invalidationCounts );
207+ }
208+
209+ /** @param list<string> $iris */
210+ public function recordCachePurge (array $ iris ): void
211+ {
212+ $ this ->cachePurgedIris = array_values (array_unique (array_merge ($ this ->cachePurgedIris , $ iris )));
213+ }
214+
215+ /** @return list<string> */
216+ public function getCachePurgedIris (): array
217+ {
218+ return $ this ->cachePurgedIris ;
219+ }
220+
221+ public function getCachePurgedCount (): int
222+ {
223+ return \count ($ this ->cachePurgedIris );
224+ }
225+
226+ // -----------------------------------------------------------------------
227+ // Private Mercure upgrades
228+ // -----------------------------------------------------------------------
229+
230+ /** @param list<string> $topics */
231+ public function recordMercurePrivateUpgrade (array $ topics , string $ resourceClass ): void
232+ {
233+ $ this ->mercurePrivateUpgrades [] = ['topics ' => $ topics , 'resourceClass ' => $ resourceClass ];
234+ }
235+
236+ /** @return list<array{topics: list<string>, resourceClass: string}> */
237+ public function getMercurePrivateUpgrades (): array
238+ {
239+ return $ this ->mercurePrivateUpgrades ;
240+ }
241+
242+ public function getMercurePrivateUpgradeCount (): int
243+ {
244+ return \count ($ this ->mercurePrivateUpgrades );
245+ }
246+
129247 // -----------------------------------------------------------------------
130248 // ResetInterface
131249 // -----------------------------------------------------------------------
@@ -142,5 +260,10 @@ public function reset(): void
142260 $ this ->pageDataFound = false ;
143261
144262 $ this ->publishedTopics = [];
263+ $ this ->publishableQueries = [];
264+ $ this ->pageDataResolutions = [];
265+ $ this ->invalidationCounts = ['created ' => 0 , 'updated ' => 0 , 'deleted ' => 0 ];
266+ $ this ->cachePurgedIris = [];
267+ $ this ->mercurePrivateUpgrades = [];
145268 }
146269}
0 commit comments