Completed
Push — master ( 82cd1d...312098 )
by Nikolas
163:59 queued 138:22
created

IndexResource::doGet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
namespace rtens\domin\delivery\web\adapters\curir\root;
3
4
use rtens\domin\delivery\web\adapters\curir\CurirBreadCrumbsTrail;
5
use rtens\domin\delivery\web\adapters\curir\CurirParameterReader;
6
use rtens\domin\delivery\web\resources\ActionListResource;
7
use rtens\domin\delivery\web\WebApplication;
8
use watoki\curir\Container;
9
use watoki\curir\cookie\CookieStore;
10
use watoki\curir\delivery\WebRequest;
11
use watoki\deli\Path;
12
use watoki\deli\Request;
13
14
class IndexResource extends Container {
15
16
    /**
17
     * @param Request|WebRequest $request
18
     * @return \watoki\curir\delivery\WebResponse
19
     */
20
    public function respond(Request $request) {
21
        if (!$this->isContainerTarget($request)) {
22
            $request = $request
23
                ->withTarget(Path::fromString('execute'))
24
                ->withArgument(ExecuteResource::ACTION_ARG, $request->getTarget()->toString());
25
        }
26
        return parent::respond($request);
27
    }
28
29
    /**
30
     * @param WebRequest $request <-
31
     * @param WebApplication $app <-
32
     * @param CookieStore $cookies <-
33
     * @return string
34
     */
35
    public function doGet(WebRequest $request, WebApplication $app, CookieStore $cookies) {
36
        $app->prepare();
37
38
        $crumbs = new CurirBreadCrumbsTrail(new CurirParameterReader($request), $cookies);
39
        $actionList = new ActionListResource($app, $crumbs);
40
41
        return $actionList->handleGet();
42
    }
43
}