Skip to content
Corex

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.

__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)”

A state-changing run must carry a valid REST nonce (Principle VII).

The cached latest result for every provider.

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).

The aggregated actionable recommendations from every provider’s latest stored result.

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).

index(WP_REST_Request $request): WP_REST_Response

Section titled “index(WP_REST_Request $request): WP_REST_Response”

run(WP_REST_Request $request): WP_REST_Response

Section titled “run(WP_REST_Request $request): WP_REST_Response”

recommendations(WP_REST_Request $request): WP_REST_Response

Section titled “recommendations(WP_REST_Request $request): WP_REST_Response”

widgetsResponse(WP_REST_Request $request): WP_REST_Response

Section titled “widgetsResponse(WP_REST_Request $request): WP_REST_Response”