about summary refs log tree commit diff stats
path: root/classes/Handler/DeletepaginationHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Handler/DeletepaginationHandler.php')
-rw-r--r--classes/Handler/DeletepaginationHandler.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/classes/Handler/DeletepaginationHandler.php b/classes/Handler/DeletepaginationHandler.php
new file mode 100644
index 0000000..28c1ab9
--- /dev/null
+++ b/classes/Handler/DeletepaginationHandler.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Handler;
+
+use ORM;
+use Request;
+use RequestHandlerInterface;
+use Response;
+
+class DeletepaginationHandler 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) {
+                $pag->delete();
+                return new Response();
+            }
+        }
+
+        return (new Response())
+            ->withStatus(404)
+            ->withBody("Not found.");
+    }
+}