InsightsController
Corex\Config\Insights\InsightsController · class · Config layer
REST for the Corex → Insights screen: GET corex/v1/insights returns the cached results (manage_options); POST corex/v1/insights/run runs one provider and stores it (manage_options and a valid REST nonce — Principle VII). Results never contain a secret (the InsightResult value carries only scores/metrics/recommendations). The pure seams (canManage, verifiedNonce, result) are unit-tested; the WP_REST_* callbacks are thin.
Public API
Section titled “Public API”__construct(InsightRegistry $registry, InsightStore $store, string $option, ?InsightRunService $runService, ?InsightWidgets $widgets, ?InsightWidgetFacts $widgetFacts)
Section titled “__construct(InsightRegistry $registry, InsightStore $store, string $option, ?InsightRunService $runService, ?InsightWidgets $widgets, ?InsightWidgetFacts $widgetFacts)”register(): void
Section titled “register(): void”canManage(): bool
Section titled “canManage(): bool”canRun(WP_REST_Request $request): bool
Section titled “canRun(WP_REST_Request $request): bool”verifiedNonce(string $nonce): bool
Section titled “verifiedNonce(string $nonce): bool”A state-changing run must carry a valid REST nonce (Principle VII).
stored(): array
Section titled “stored(): array”The cached latest result for every provider.
result(string $providerId): ?array
Section titled “result(string $providerId): ?array”Run one provider against the site URL, cache it, and return its (secret-free) payload — or null if the provider id is unknown (the route maps that to a 404).
recommendationList(): array
Section titled “recommendationList(): array”The aggregated actionable recommendations from every provider’s latest stored result.
widgetList(): array
Section titled “widgetList(): array”The full designed Insights widget set, built from real gathered facts. Empty when the widget model/facts collaborators are not wired (kept optional so the pure seams stay testable).