diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:06:30 +0300 |
| commit | fa1bccd968647f6ab5cce0ec4293b39c6fde7633 (patch) | |
| tree | a51b489a43bdfcc2688bd0855cf3e32382ad958c /classes/Handler/PaginationHandler.php | |
| parent | ab7702f0e3dd63bdeaea3cb6db138878774c3b47 (diff) | |
| download | the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.gz the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.xz | |
spaces to tabs
Diffstat (limited to 'classes/Handler/PaginationHandler.php')
| -rw-r--r-- | classes/Handler/PaginationHandler.php | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/classes/Handler/PaginationHandler.php b/classes/Handler/PaginationHandler.php index c126762..7015dfc 100644 --- a/classes/Handler/PaginationHandler.php +++ b/classes/Handler/PaginationHandler.php @@ -10,71 +10,71 @@ use Response; class PaginationHandler implements RequestHandlerInterface, AuthRequired { - private function handleGet(int $bookid): Response - { - if ($bookid) { - $pag = ORM::for_table('epube_pagination') - ->where('bookid', $bookid) - ->find_one(); + private function handleGet(int $bookid): Response + { + if ($bookid) { + $pag = ORM::for_table('epube_pagination') + ->where('bookid', $bookid) + ->find_one(); - if ($pag) { - return (new Response())->withBody($pag->pagination); - } - } + if ($pag) { + return (new Response())->withBody($pag->pagination); + } + } - return (new Response()) - ->withStatus(404) - ->withBody("File not found."); - } + return (new Response()) + ->withStatus(404) + ->withBody("File not found."); + } - private function handleStore(int $bookid, ?string $payload): Response - { - if ($bookid && $payload) { - $pag = ORM::for_table('epube_pagination') - ->where('bookid', $bookid) - ->find_one(); + private function handleStore(int $bookid, ?string $payload): Response + { + if ($bookid && $payload) { + $pag = ORM::for_table('epube_pagination') + ->where('bookid', $bookid) + ->find_one(); - if (!$pag) { - $pag = ORM::for_table('epube_pagination')->create(); - $pag->bookid = $bookid; - } + if (!$pag) { + $pag = ORM::for_table('epube_pagination')->create(); + $pag->bookid = $bookid; + } - $pag->pagination = $payload; - $pag->total_pages = 100; - $pag->save(); - } + $pag->pagination = $payload; + $pag->total_pages = 100; + $pag->save(); + } - return new Response(); - } + return new Response(); + } - private function handleDelete(int $bookid): Response - { - if ($bookid) { - $pag = ORM::for_table('epube_pagination') - ->where('bookid', $bookid) - ->find_one(); + private function handleDelete(int $bookid): Response + { + if ($bookid) { + $pag = ORM::for_table('epube_pagination') + ->where('bookid', $bookid) + ->find_one(); - if ($pag) { - $pag->delete(); - return new Response(); - } - } + if ($pag) { + $pag->delete(); + return new Response(); + } + } - return (new Response()) - ->withStatus(404) - ->withBody("Not found."); - } + return (new Response()) + ->withStatus(404) + ->withBody("Not found."); + } - public function handle(Request $request): Response - { - $subOp = $request->getAttribute('op', ''); - $bookid = (int) $request->getAttribute('id'); + public function handle(Request $request): Response + { + $subOp = $request->getAttribute('op', ''); + $bookid = (int) $request->getAttribute('id'); - return match ($subOp) { - 'getpagination' => $this->handleGet($bookid), - 'storepagination' => $this->handleStore($bookid, $request->getAttribute('payload')), - 'deletepagination' => $this->handleDelete($bookid), - default => (new Response())->withStatus(404)->withBody("Not found."), - }; - } + return match ($subOp) { + 'getpagination' => $this->handleGet($bookid), + 'storepagination' => $this->handleStore($bookid, $request->getAttribute('payload')), + 'deletepagination' => $this->handleDelete($bookid), + default => (new Response())->withStatus(404)->withBody("Not found."), + }; + } } |
