metricoolApi = $metricoolApi; $this->dashboard = $dashboard; } /** * @inheritDoc */ public function registerRoute(): string { return self::ROUTE; } /** * @inheritDoc */ public function enabled(): bool { return $this->adminAccessAllowed(); } /** * @inheritDoc */ public function registerArguments(): array { return [ 'methods' => \WP_REST_Server::EDITABLE, 'callback' => [$this, 'callback'], 'middleware' => ['metricool:auth'], ]; } /** * Log the user out and redirect to the dashboard */ public function callback(\WP_REST_Request $request): \WP_REST_Response { $this->metricoolApi->logout(); return $this->sendHttpResponse([ 'state' => $this->dashboard->state(), 'mode' => $this->dashboard->mode(), ]); } }