Parcourir la source

Add API route for userWatchStatsSimple plugin

- Add GET /api/v2/homepage/userWatchStatsSimple route
- Route calls getUserWatchStatsSimple() method from HomepageUserWatchStatsSimple trait
- Required for plugin to function properly in settings interface and homepage display
- Ensures save button and form interactions work correctly
mgomon il y a 8 mois
Parent
commit
782d45a96a
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8 0
      api/v2/routes/homepage.php

+ 8 - 0
api/v2/routes/homepage.php

@@ -629,3 +629,11 @@ $app->get('/homepage/userWatchStats', function ($request, $response, $args) {
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
 });
+$app->get('/homepage/userWatchStatsSimple', function ($request, $response, $args) {
+	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+	$Organizr->getUserWatchStatsSimple();
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
+});