about summary refs log tree commit diff stats
path: root/classes/Handler/GetpaginationHandler.php
diff options
context:
space:
mode:
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.");
+    }
+}