about summary refs log tree commit diff stats
path: root/classes/Handler/GetpaginationHandler.php
blob: 8ecf92dbec58875b6efee74c5da1af77bab76907 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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.");
    }
}