about summary refs log tree commit diff stats
path: root/classes/Handler/GetpaginationHandler.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-24 14:16:07 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-24 14:16:07 +0300
commit1bdf80397c19362c019cdd231e8813e251764370 (patch)
tree126c1e0ffcc5664ac2b5883bec64007070411a9b /classes/Handler/GetpaginationHandler.php
parent1917ab77550613654620b6f5d4ad8570704246de (diff)
downloadthe-epube-1bdf80397c19362c019cdd231e8813e251764370.tar.gz
the-epube-1bdf80397c19362c019cdd231e8813e251764370.tar.xz
switch to PSR-4 router with namespaced handlers
Diffstat (limited to 'classes/Handler/GetpaginationHandler.php')
-rw-r--r--classes/Handler/GetpaginationHandler.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/classes/Handler/GetpaginationHandler.php b/classes/Handler/GetpaginationHandler.php
new file mode 100644
index 0000000..8ecf92d
--- /dev/null
+++ b/classes/Handler/GetpaginationHandler.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Handler;
+
+use ORM;
+use Request;
+use RequestHandlerInterface;
+use Response;
+
+class GetpaginationHandler implements RequestHandlerInterface
+{
+    public function handle(Request $request): Response
+    {
+        $bookid = (int) $request->getAttribute('id');
+
+        if ($bookid) {
+            $pag = ORM::for_table('epube_pagination')
+                ->where('bookid', $bookid)
+                ->find_one();
+
+            if ($pag) {
+                return (new Response())->withBody($pag->pagination);
+            }
+        }
+
+        return (new Response())
+            ->withStatus(404)
+            ->withBody("File not found.");
+    }
+}